Assets does not see subfolders

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.


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.

Tags:

Flutter