I developed separated UI package for my project.
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);
...
}
The question is - How can I use 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
:This solution applies to all types to assets outside root app package.