I am trying to add images to my flutter app via assets. this is the where i have linked the images. this is the pubspec yaml file Tried different ways. nothing seems to work.
Asked
Active
Viewed 443 times
-1
-
You should use Image.asset widget and then as the first parameter you put the path to your image as a String. – Vayhuit Oct 04 '21 at 13:52
-
first change your line in pubspec -images to -assets/images then run pubget and then u can access the images – Awais Rehman Oct 04 '21 at 14:07
2 Answers
1
First of all create a folder in your project named assets, not in your lib folder. After that in pubspace.yaml define your folder like this assets/images/

MuhammedYesilmen
- 129
- 1
- 12
0
You are doing wrong thing in pubspace.yaml. Maintain whitespaces as shown in below
flutter:
assets:
- assets/

G H Prakash
- 1,720
- 10
- 30