美文网首页
flutter 添加图标的实现

flutter 添加图标的实现

作者: 别看后面有人 | 来源:发表于2023-07-23 19:46 被阅读0次

阿里图标地址:https://www.iconfont.cn/
选择好图标之后------》选择下载代码
然后复制进项目中

image.png
具体的使用
第一步:先新建图标代码:代码中的 0xe607来源于上图中的json中
image.png
class MyIcon{
  static const IconData category=IconData(
    0xe607,
    fontFamily: 'MyIcon',
    matchTextDirection: true
  );
  static const IconData redPagecaket=IconData(
      0xe608,
      fontFamily: 'MyIcon',
      matchTextDirection: true
  );
  static const IconData custom=IconData(
      0xe609,
      fontFamily: 'MyIcon',
      matchTextDirection: true
  );
}

第二步使用方法:

 children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            Icon(MyIcon.category,color: Colors.red,)
          ],

当然前提是先添加资源文件


image.png

相关文章

网友评论

      本文标题:flutter 添加图标的实现

      本文链接:https://www.haomeiwen.com/subject/txfqpdtx.html