[FR]: Asset path as const
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the problem
I have several const that defines some static data in my app.
Before using flutter_gen, I could write something like this :
const breath = MultiSelectorItem('breath', 'assets/breath.svg', 'Breath');
But when using flutter_gen, this line doesn't work anymore :
const breath = MultiSelectorItem('breath', Assets.breath.path, 'Breath');
Describe the solution
It seems that it's because the generated class SvgGenImage.path is a getter, so NOT const.
class SvgGenImage {
const SvgGenImage(this._assetName);
final String _assetName;
[...]
String get path => _assetName;
String get keyName => _assetName;
}
Do you have an idea how can I use the asset path in a const ?
Additional context
I now I could remove flutter_svg: true in pubspec, but using this kind of code is also handy :
child: Assets.breath.svg()
Request looks similar to #351, but it is somewhat different.
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Even though this looks good. If its related to data or state, I think you should separate UI and logic. Create enum instead, and use switch from that.
child: switch(enumValue) {
SomeEnum.Type1: Assets.breath.svg(),
....
}