1
Your suggestion to organize assets by placing them in a dedicated folder and referencing the folder path in the pubspec.yaml
file is a good practice for better project organization. This approach makes it easier to manage assets, especially when there are multiple assets of the same type.
However, when specifying the folder path in the pubspec.yaml
file, it's important to note that you should include the trailing slash (/) at the end of the folder path to ensure that all assets within that folder are correctly included. Without the trailing slash, only the folder itself will be included, not its contents.
assets:
- assets/icons/
After adding or modifying assets in the project, running flutter pub get
is necessary to update the asset bundle. In case of any issues, running flutter clean
followed by flutter pub get
can help resolve any inconsistencies.
1
Rather than adding assets file in pubspec.ymal like this,
assets:
- assets/icons/bed-reversal.jpg
- assets/icons/chair.jpg
- assets/icons/comfort.jpg
- assets/icons/decor.jpg
- assets/icons/sofas.jpg
You can add like this
assets:
- assets/icons/
and after that you have to do the flutter pub get, If you are still facing the issue then please do the flutter clean and run the flutter pub get command again. mak sure you have created the folder assets/icons in your root project and having all the required icons over there.