Use Ali’s iconfont in Flutter

download

Put iconFont. TTF and iconfont. CSS in assets/fonts/ folder

configuration

Configure fonts

flutter:
  fonts:
    - family: IconFont
      fonts:
        - asset: assets/fonts/iconfont.ttf
Copy the code

Install the pub package

The iconfont_css_to_class package can convert iconfont. Dart from iconfont. CSS

Dependencies: iconfont_css_to_class: git: url: https://gitee.com/yin_shiyong/iconfont_css_to_class.git ref: 0.1.3Copy the code

Generate iconfont. Dart

Make sure you have created the lib/common folder before running

The terminal runs the flutter pub run iconfont_css_to_class:main

After updating iconfont. TTF and iconfont. CSS, run the command to update the iconfont

Using iconfont

import 'package:sounding/common/iconfont.dart';

Icon(
  IconFont.icon_yuqiedian1,
  size: 16,
)
Copy the code