Multiple assets in Flutter project

Sadly, you can't import the whole assets/ folder at once but you can now import all the assets inside a folder.

# ❌ Don't Import every files inside assets folder, its tiring ❌             
assets:
  - assets/audio/celebrate.mp3
  - assets/audio/splash.mp3
  - assets/lottie/paper_plane.json
  - assets/lottie/celebration.json
  - assets/images/png/stats.png
  - assets/images/alert.svg

# ❌ Import all assets at once,🚨 Not allowed ❌
assets:
  - assets/        

# ✅ Just import every folders inside assets ✅
assets:
  - assets/lottie/
  - assets/images/svg/
  - assets/images/png/
  - assets/audio/

Yes, currently this is required and a known limitation.

Wildcarding assets in pubspec.yaml (or allow an entire directory to be included) #4890

You could use code generation to get the assets listed all at once, but you'll also get into troubles when the list becomes too long.


This is no longer a restriction. You can now include all assets in a directory.

In the flutter docs it states:

To include all assets under a directory, specify the directory name with the / character at the end:

flutter:
  assets:
    - directory/
    - directory/subdirectory/

Tags:

Flutter