Here is it's simplified structure:
project:
│
...
│
├── lib:
│ │
│ └── classes using AppIcons.ttf:
│
└── packages:
│
└── ui-kit:
│
├── lib:
│ │
│ └── classes using AppIcons.ttf:
│
└── assets:
│
└── icons:
│
└── AppIcons.ttf:
packages/ui-kit/pubspec.yaml
:
flutter:
fonts:
- family: AppIcons.ttf
fonts:
- asset: assets/icons/AppIcons.ttf
packages/ui-kit/app_icons.dart
:
abstract class AppIcons {
static const _kFontFam = 'AppIcons';
static const IconData ic_add = IconData(0xe800, fontFamily: _kFontFam);
...
}
AppIcons.ic_add
inside lib/
So when I tried to place icon (Icon(AppIcons.ic_add)
) I always get placeholder instead of my icon
Finally I solved this question.
For those who faced the same problem here is my solution:
packages/ui-kit/app_icons.dart
:
...
flutter:
fonts:
- family: AppIcons.ttf
fonts:
- asset: packages/ui-kit/assets/icons/AppIcons.ttf
...