image asset icon name must be set

534 views Asked by At

while adding image asset to my flutter app, whatever the name i set the error still the same and refuse to add the image enter image description here

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

1

There are 1 answers

1
AudioBubble On BEST ANSWER

These are the steps on how to add images in Flutter.

  1. 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

  2. Open pubspec.yaml file and add the following lines there (Keep a note to the spaces)

    assets:        
      - assets/your_image.jpg
    
  3. Run flutter packages get in terminal.

  4. You can now use your image in your code like this

    AssetImage("assets/your_image.jpg")