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

Time:03-04

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

CodePudding user response:

Did you tried to add your image in asset folder in your project directory?

CodePudding user response:

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'),

CodePudding user response:

1- make sure you write image path correctly

2- write this commend in terminal

flutter pub get

or if you use vsCode ope pubspec.yaml and click Ctrl s

  • Related