随笔 - 210  文章 - 0 评论 - 0 阅读 - 61289
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

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),
 4.使用图片代替图标
复制代码
GestureDetector(
onTap: () {
// 点击图标后执行的操作 print("点击了"); }, child: Image.asset( 'images/home/setting.png', width: height / 10, height: height / 10, ), ),

IconButton( //最好用上方的
  onPressed: () {
    // 点击图标后执行的操作(如果下方有文字间距太大)
    print("点击了");
  },
  icon: Image.asset(
    'images/home/page.png',
    width: 10,
    height: 10,
  ),
),
复制代码

 

posted on   鲤斌  阅读(14)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示