Reputation: 35
I have custom font icon file named myicons.ttf and myJsonValue.json file with all values defined in it. How to implement icons with these in flutter? I have defined properly in the pubspec.yaml.
flutter:
fonts:
- family: icons
fonts:
- asset: assets/fonts/myicons.ttf
assets:
- res/myJsonValue.json
Upvotes: 3
Views: 4372
Reputation: 89
Use this code its work my app
Icon(
IconData(0xE905,fontFamily: 'DCB',),color: Colors.green,
size: 50,
)
0x is constant and E905 is ttf file icon code
Upvotes: 0
Reputation: 657238
const myIcon = const IconData('\u1234', fontFamily: 'icons');
then use it like
const Icon(myIcon);
See also https://github.com/flutter/flutter/blob/c97fc2063f7b5b1a3a9bdb937205a237e13246a2/packages/flutter/lib/src/material/icons.dart#L29 how to create a set of icon data (one for each icon)
Upvotes: 3