📁 Deep Dive · Beginner

Ship only the assets each platform needs

One flutter: assets list used to mean every platform received every file. From 3.41 you can filter:

Diagram: Platform-specific Assets

flutter:
  assets:
    - path: assets/logo.png
    - path: assets/web_worker.js
      platforms: [web]
    - path: assets/desktop_icon.png
      platforms: [windows, linux, macos]

Why this is not optional for multi-platform apps

  • Mobile users should not download desktop help PDFs or web workers.
  • Store size metrics and download friction improve immediately.
  • CI can assert platform asset matrices in tests.

Practical split

Asset typePlatforms
Shared brandingall
Web workers / wasm helpersweb
High-res print templatesdesktop
iOS/Android notification soundsandroid, ios

Pitfalls

  • Conditional rootBundle.load of a missing platform asset throws — guard with a platform check.
  • This is packaging filtering, not runtime theming.
#Flutter#Assets#AppSize#pubspec