在pubspec.yaml文件,添加字体文件
# example:
fonts:
- family: glyphicons
fonts:
- asset: lib/assets/icons/glyphicons.ttf
- family: awesome
fonts:
- asset: lib/assets/icons/awesome.ttf
- family: icomoon
fonts:
- asset: lib/assets/icons/icomoon.ttf
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
更多信息 官方文档:https://flutter.dev/custom-fonts/#from-packages
调用
Icon(
IconData(codePoint,
fontFamily: icon.contains("glyphicons")
? "glyphicons"
: icon.contains("icomoon")
? "icomoon"
: "awesome"),
),