I have given two white spaces for assets and 4 white spaces for the image location but also I am getting the error.
This is my pubspec.yaml
flutter:
uses-material-design: true
assets:
- assets/port.jpeg
I am getting the error
════════ Exception caught by image resource service ════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/port.jpeg
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw_
packages/flutter/src/services/asset_bundle.dart 227:55 load
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn>
dart-sdk/lib/async/zone.dart 1362:47 _rootRunUnary
dart-sdk/lib/async/zone.dart 1265:19 runUnary
...
Image provider: AssetImage(bundle: null, name: "assets/port.jpeg")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#5a8a3(), name: "assets/port.jpeg", scale: 1)
════════════════════════════════════════════════════════════════════════════════════════════════════
This is my directory
Just make a hot restart. If that doesn't fix your problem, uninstall and re-run your app in your emulator and you'll be fine
write your asset as:-
assets:
- assets/
assets:
- assets/port.jpeg
Also, make sure the extension of the image matches the destination image extension.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.