iconfont_builder 0.1.0 copy "iconfont_builder: ^0.1.0" to clipboard
iconfont_builder: ^0.1.0 copied to clipboard

outdated

Build Iconfont to Flutter Icon

iconfont_builder #

映射 Iconfont 至 Flutter IconData 或 Icon 组件

API #

API: https://pub.dev/documentation/time_log/latest/time_log/iconfont_builder.html

准备工作 #

Iconfont 网站选择上下载字体包,解压并拷贝 demo_index.htmliconfont.ttf 到项目中

- your-project
    - ios
    - android
    - lib
    - fonts
      # 根据此 html 文件进行解析,所以编译前需要保留
      demo_index.html
      iconfont.ttf

编辑 pubspec.yaml, 引用文字资源

fonts:
  - family: Iconfont
    fonts:
      - asset: fonts/iconfont.ttf

安装 iconfont 至 dart 全局 #

Install:

$ pub global activate iconfont_builder

在 Flutter 中使用 Iconfont #

使用 IconData 模式 #

使用 iconfont 编译 Iconfont.dart

$ iconfont_builder --from ./fonts --to ./lib/Iconfont.dart
import './Iconfont.dart';

void main() {
  // iconfont 中的图标名字都会映射置 Iconfont 对象中
  // Iconfont.name 是一个 IconData 对象
  final theIcon = Icon(Iconfont.name);
}

使用 Icon 组件模式 #

使用 iconfont 编译 Iconfont.dart, 添加 --type Icon 命令

$ iconfont_builder --type Icon --from ./fonts --to ./lib/Iconfont.dart
import './Iconfont.dart';

void main() {
  // 此时,Iconfont.name 是一个函数,直接返回一个 Icon 组件
  final theIcon = Iconfont.data();
}

查看帮助 #

$ iconfont_builder --help
5
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Build Iconfont to Flutter Icon

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

args, lpinyin

More

Packages that depend on iconfont_builder