skip to Main Content

I have an image folder called images on the lib folder (lib/images/logo.png) but when I tried inserting the image on my flutter page I keep getting this error message:

Image provider: AssetImage(bundle: null, name: "lib/images/logo.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#c350c(), name: "lib/images/logo.png",
scale: 1)

Here is the code:

 Image.asset(
   'lib/images/logo.png',
    width: 180,
 ),

I have carefully checked the images folder to be double sure the image is there and it is there. What could be the reason for this error.

2

Answers


  1. Chosen as BEST ANSWER

    I have been able to fix it by running flutter clean and flutter pub get. But I don't know which among both command got it to work.


  2. Check if it is correctly added in your pub spec.yaml file ,try to restart your editor.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search