Icon(Icons.search,color: Colors.red,size: 40),
图 标 官 网 Flutter
Flutter中借助阿里巴巴图标库自定义字体图标
1. 导入字体图标文件;
fonts:
- family: myIcon #根据自己的需求定义
fonts:
- asset: fonts/iconfont.ttf
2、 为了使用方便,我们定义一个 MyIcons 类,功能和 Icons 类一样
class MyIcons{
// book 图标
static const IconData book = IconData(
0xe614,
fontFamily: 'myIcon',
matchTextDirection: true
);
// 微信图标
static const IconData wechat = IconData(
0xec7d,
fontFamily: 'myIcon',
matchTextDirection: true
);
}
3、 使用
Icon(MyIcons.book,color: Colors.purple),