assets does not see subfolders.
If folder /image.png
- then all the rules.
If folder /subfolder/image.png
- writes:
Unable to load asset
Is there a solution or is it supported?
Required for offline maps in flutter_map.
All you need is to provide all folders and subfolders.
Check official doc:
Note that only files located directly in the directory will be included; to add files located in subdirectories, create an entry per directory.
But if you need to provide different scales (like 1.5x, 2.0x, 3.0x) you don't need to mention these subfolders in pubspec.yaml.
I had similar problem when started, and my problem was:
Add asset file to pubspec, like
flutter:
assets:
- subfolder/image.png
Then using it like AssetImage('mage.png')
The problem here was that you should still provide the full path, as in: AssetImage(subfolder/image.png)
Please check AssetImage class for more examples.
Not sure what the problem is exactly, but you need to list every folder that contains assets. The files in the listed folder and in resolution sub-folders (like 1.5x/
, 2.0x
, 3.0x
, ...) are then found automatically,
but other sub-folders are ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With