阿里圖標地址: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