flutter 添加圖標(biāo)的實(shí)現(xiàn)

阿里圖標(biāo)地址:https://www.iconfont.cn/
選擇好圖標(biāo)之后------》選擇下載代碼
然后復(fù)制進(jìn)項目中

image.png

具體的使用
第一步:先新建圖標(biāo)代碼:代碼中的 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,)
          ],

當(dāng)然前提是先添加資源文件


image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容