Search code examples
androidflutterdartyamlpubspec

I have a problem when i try to access the image /assets in Flutter


This is an error when I run the program, so I am a newbie in this language(Click to see an image)

This is my file "pubspec.yaml ", I think I corrected every syntax and space, but it still happens this error(Click to see an image) And this


Solution

  • Try below code hope its help to you.

    Make sure you have create assets folder in your project working directory, put your images in assets folder and write below code in your pubspec.yaml file.

    Refer adding assets in your project here

    Your pubspec.yaml file

    assets:
        - assets/
    

    Your Widget:

    Image.asset('assets/human.jpg'),