Home > Enterprise >  flutter unable to load image assets
flutter unable to load image assets

Time:10-15

this how I called image in my app

Image.asset('assets/user.jpg')

this is my pubspec.yaml

assets:
   -assets/user.jpg
   

and I get this error

Exception has occurred. FlutterError (Unable to load asset: assets/user.jpg)

CodePudding user response:

You must consider indentation for assets in pubspec.yaml

assets:
  - assets/user.jpg

CodePudding user response:

  1. Your indentation is not correct. It should be like this:
assets:
  - assets/user.jpg
  1. Make sure user.jpg is placed in assets folder in your project's main directory (not inside lib folder)

  2. After doing this, make sure you rebuild your app to see these changes.

  • Related