skip to Main Content

getting this error again & again but the image path is perfectly alright & dependecy is added properly in the yamal file!

Exception has occurred.
FlutterError (Unable to load asset: "assets/images/profile.png".
Exception: Asset not found)

assets:
– assets/images

this dint soleved the proble

2

Answers


  1. If you want to add all the assets in a folder (say "images" folder), you should add "/" at the end as below in pubspec.yaml.

      assets:
        - assets/images/
    
    Login or Signup to reply.
  2. Follow the following steps:

    1. Create the folders called assets/images inside project but outside lib folder.
    2. Now Open pubspec.yaml and add:

    enter image description here

    (The indents must be precise)

    1. After updating pubspec.yaml close the app and RUN IT AGAIN.
    2. Now your code will work:
    Container(
      height: 200, //As per your requirement
      width: 200,//As per your requirement
      child: Image(
        image: AssetImage(
          'assets/images/profile.png',
        ),
        fit: BoxFit.cover,
      )
    )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search