SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Dart New Added 26 October 2026

Flutter: Unable to load asset: "assets/images/logo.png"

The file is on disk but not in the app bundle, because Flutter only packages what pubspec.yaml lists under flutter: assets:. Usual causes: YAML indentation (assets: must sit two spaces under flutter:, not at the top level), a folder listed without its trailing slash, or expecting a folder entry to include its subfolders, which it does not. The path in code must match exactly, including case. Hot reload does not pick up new assets either, so even a correct pubspec fails until a full restart.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Check the indentation: assets belongs under flutter:
grep -n -A 8 "^flutter:" pubspec.yaml

# pubspec.yaml
# flutter:
#   uses-material-design: true
#   assets:
#     - assets/images/          # trailing slash: every file in this folder
#     - assets/images/icons/    # subfolders must be listed separately

# List what really made it into the bundle, from inside the app
# final manifest = await AssetManifest.loadFromAssetBundle(rootBundle);
# debugPrint(manifest.listAssets().join("\n"));

flutter pub get

# New assets need a full restart, not a hot reload
flutter run

How to diagnose Dart errors

Dart errors are dominated by null safety at runtime and version solving at build time. The null-check operator failure (! on a null) is Dart's equivalent of a NullPointerException and almost always means an assumption about initialisation order was wrong. Pub version solving failures are dependency-graph conflicts and are solved by reading the constraint that pub reports as unsatisfiable, not by deleting the lockfile.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Read the full pub get output. It names the two packages whose constraints conflict. Deleting pubspec.lock hides that information without fixing anything.
  2. Replace ! with a null check plus a meaningful error, or with late final where initialisation genuinely happens before first use. The crash location is where the assumption broke.
  3. Run flutter doctor -v before debugging any build failure. It catches missing Android SDK components and licence acceptance, which produce misleading Gradle errors.
  4. Use dart pub deps --style=tree to see the resolved graph and find which transitive dependency is pinning an old version.
  5. Clear derived state with flutter clean only after you have read the error. It resets the symptom and loses the evidence.

Tools worth reaching for

  • flutter doctor -v
  • dart pub deps
  • dart analyze
  • flutter run --verbose

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

docs.flutter.dev

Related Dart errors

See all 20 Dart errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.