How to add images in vscode - Flutter

3,464

use relative path to indicate the folder(e.g.myImages) that hosts your image assets. then

flutter:
  assets:
    - myImages/android.png

see flutter doc for more info:

Adding assets and images

Share:
3,464
C.Calzana
Author by

C.Calzana

Updated on December 17, 2022

Comments

  • C.Calzana
    C.Calzana over 1 year

    I am trying to add images to an asset folder in VSCode, but I only get the option to type the image name. When I do and click on the newly created image, it says "an error has occurred." I presume this is because I am only typing the file name, not adding the actual image.

    I added the full path to the yml file, but nothing loads in the app.

    assets:
        - C:/Users/tt/Desktop/Flutter_projects/Practise/imaages/images/assets/android.png
    
    

    Flutter code:

    child: Image(
        image: AssetImage('assets/android.png')
      ),
    ),