flutter_gen
flutter_gen copied to clipboard
flutter gen 1x 2x 3x support is not friendly
For example, I don't need 1x image, how to deal with it?
assets/
images/
2.0x/a.png
3.0x/a.png
assets:
- assets/images/
i think, flutter_gen should generate:
assets:
- assets/images/
- assets/images/a.png # generated
- ....
class $AssetsImagesGen {
const $AssetsImagesGen();
/// File path: assets/images/a.png
AssetGenImage get a =>
const AssetGenImage('assets/images/a.png');
}
in this way, won't this file get very large?
in this way, won't this file get very large?
just use 3x ? Not so friendly for low memory devices
any update?
I'm confused what the problem is.
Flutter's Resolution aware images is what determines how the assets are imported/used. FlutterGen is just following its convention.
However, https://stackoverflow.com/a/60522464/88646 shows a workaround for flutter, where you can specify the 1.0x image, without it actually being included. Perhaps that will do what you need?
I've come across an issue similar to the one mentioned before in my project when using Flutter Gen for asset generation. My assets are organized as follows:
- assets/images/2.0x/
- assets/images/3.0x/
However, during the generation process, I encounter an error. The specific issue is illustrated in the following screenshot:
Maybe this is the support that is mentioned in this issue. I suspect this issue might be related to the parsing process. It appears that Flutter Gen attempts to create a variable starting with a number.
Flutter Version:
3.13.7
Flutter Gen Package Version:
5.3.2
same issue
The gen plugin provides no extra handling than what Flutter has already done. Resolution-aware resources are designed to be organized as primary resource + variants folders. Assets in variant folders without a primary resource will not recognized as a varianted resource. For variant assets, do not include them in the pubspec, which will help to produce valid generated code, or try excluding your variant pattern in the build configuration.