image asset icon name must be set
These are the steps on how to add images in Flutter.
Add your image file to assets folder, you may have to create this folder if it is already not present. Create this folder in your /package root directory
Open pubspec.yaml file and add the following lines there (Keep a note to the spaces)
assets: - assets/your_image.jpg
Run
flutter packages get
in terminal.You can now use your image in your code like this
AssetImage("assets/your_image.jpg")
Ahmed El Sayed
Updated on December 06, 2022Comments
-
Ahmed El Sayed 19 minutes
while adding image asset to my flutter app, whatever the name i set the error still the same and refuse to add the image
my flutter doctor output
/home/ahmed/flutter/bin/flutter --no-color doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel beta, v0.5.1, on Linux, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) [✓] Android Studio (version 3.1) [✓] Connected devices (1 available)
• No issues found! Process finished with exit code 0
-
Günter Zöchbauer about 4 yearsSee flutter.io/assets-and-images about how to add assets
-
-
F-1 about 4 yearsIf you have lots of assets you can just write -assets/ this will tell Flutter that all files within the directory