flutter使用阿里巴巴图标

从Iconfont中下载资源放到项目根目录/assets/fonts文件夹下

把iconfont.ttf 和 iconfont.json放到里面即可

在pubspec.yaml中配置资源路径

复制代码
flutter:
      fonts:
        - family: ityingIcon #指定一个字体名 根据自己的需求定义
          fonts:
              - asset: assets/fonts/iconfont.ttf

创建图标类 ityingIcons

复制代码
import 'package:flutter/material.dart';

class ItyingIcons {
  static const IconData xiaomi =
      IconData(0xe623, fontFamily: 'ityingIcon', matchTextDirection: true);

  static const IconData weixiufuwu =
      IconData(0xead5, fontFamily: 'ityingIcon', matchTextDirection: true);
}

使用

复制代码
const Icon(ItyingIcons.xiaomi, color: Colors.white),
相关推荐
GISer_Jing34 分钟前
前端面试通关:Cesium+Three+React优化+TypeScript实战+ECharts性能方案
前端·react.js·面试
落霞的思绪1 小时前
CSS复习
前端·css
咖啡の猫3 小时前
Shell脚本-for循环应用案例
前端·chrome
百万蹄蹄向前冲6 小时前
Trae分析Phaser.js游戏《洋葱头捡星星》
前端·游戏开发·trae
笔沫拾光6 小时前
iOS 正式包签名指南
flutter·ios·ios签名
朝阳5816 小时前
在浏览器端使用 xml2js 遇到的报错及解决方法
前端
GIS之路6 小时前
GeoTools 读取影像元数据
前端
ssshooter7 小时前
VSCode 自带的 TS 版本可能跟项目TS 版本不一样
前端·面试·typescript
你的人类朋友7 小时前
【Node.js】什么是Node.js
javascript·后端·node.js
Jerry8 小时前
Jetpack Compose 中的状态
前端