I'm want to make a simple flutter app and want to add an image from my assets, I already try but the image still unable to load. This is how I load the image
Image.asset('assets/images/food.jpg')
pubspec.yaml code :
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/food.jpg
debug:
I/flutter (18975): The following assertion was thrown resolving an image codec:
I/flutter (18975): Unable to load asset: assets/images/food.jpg
I/flutter (18975): Unable to load asset: assets/images/food.jpg
I/flutter (18975):
I/flutter (18975): When the exception was thrown, this was the stack:
I/flutter (18975): #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
I/flutter (18975): <asynchronous suspension>
I/flutter (18975): #1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:433:44)
I/flutter (18975): <asynchronous suspension>
I/flutter (18975): #2 AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:418:14)
I/flutter (18975): #3 ImageProvider.resolve.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:285:105)
I/flutter (18975): #4 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:157:22)
I/flutter (18975): #5 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:285:82)
I/flutter (18975): (elided 13 frames from package dart:async)
I/flutter (18975):
I/flutter (18975): Image provider: AssetImage(bundle: null, name: "assets/images/food.jpg")
I/flutter (18975): Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#df91c(), name: "assets/images/food.jpg",
I/flutter (18975): scale: 1.0)
This is my image folder look like :