Reputation: 29
The Error:
======= Exception caught by image resource service ================================================ The following assertion was thrown resolving an image codec: Unable to load asset: images/google-logo.png
My 'pubspec.yaml' file:
'''flutter:
uses-material-design: true
assets:
- images/facebook-logo.png
- images/google-logo.png '''
I am loading the image into the page using the following code: IN 'sign in page.dart' file:
'''CustomRaisedButton(
child: Image.asset('images/google-logo.png'),
color: Colors.white,
onPressed: () {},
),'''
Upvotes: 1
Views: 6367
Reputation: 216
Specify Image path as follows
Image.asset("assets/images/car_android.png")
OR
Image(image: AssetImage("assets/images/car_android.png"))
The problem is flutter can't recognize where your image is exactly stored.
If the problem continues then try to do HOT RESTART this will solve your problem.
If you update pubspec.yaml file then run flutter pub get
to update the libraries if your IDE doesn't update it automatically.
Upvotes: 0
Reputation: 19
First set your image path in pubspec.yaml file's assets
propety, Uncomment it and write path for you image folder like.,
flutter:
[2 whitespaces or 1 tab]assets:
[4 whitespaces or 2 tabs]- assets/images/ #path of your image folder
Do pub get
once, and can use the images from given path folder.
If your problem is not resolved yet. I think your assets are not loading, use Following commands in terminal,
flutter clean
flutter pub get
Restart or Reinstall the application.
Upvotes: 2