【问题标题】:How to draw icons in flutter with custom icon font file?如何使用自定义图标字体文件在颤动中绘制图标?
【发布时间】:2018-10-08 06:11:48
【问题描述】:

我有名为 myicons.ttf 的自定义字体图标文件和 myJsonValue.json 文件,其中定义了所有值。如何在颤振中实现这些图标?我已经在 pubspec.yaml 中正确定义了。

flutter:
fonts:
- family: icons
  fonts:
    - asset: assets/fonts/myicons.ttf

assets:
  - res/myJsonValue.json

【问题讨论】:

    标签: dart flutter


    【解决方案1】:
    const myIcon = const IconData('\u1234', fontFamily: 'icons');
    

    然后像这样使用它

    const Icon(myIcon);
    

    另见https://github.com/flutter/flutter/blob/c97fc2063f7b5b1a3a9bdb937205a237e13246a2/packages/flutter/lib/src/material/icons.dart#L29如何创建一组图标数据(每个图标一个)

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 2013-12-28
      • 2023-03-13
      • 1970-01-01
      • 2021-11-18
      • 1970-01-01
      • 2021-11-29
      • 2011-01-20
      • 2019-11-05
      相关资源
      最近更新 更多