1
votes

The image is not displayed, like all the paths are correctly set. You can see the code.enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

2
if you added images when your app was running and you did hot reload then may also this occur. i suggest you to stop app and do flutter clean and run you app again. - Viren V Varasadiya

2 Answers

2
votes

The issue is because of indentation. Try using a reformat of pubspec file and it will work perfectly.
Try like below Example:

name: my_flutter_app
description: A new Flutter application.

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true,
  assets:
    - assets/images/icon1.png
    - assets/images/icon2.png
    - assets/images/icon3.png
    - assets/images/icon4.png
    - assets/images/icon5.png

*dash (-) of image must be below the second 's' of assets.

1
votes

You are getting the error because your indentation in the pubspec.yalm file is wrong.

Try correcting the indentation. Use the code below: It works perfectly fine.

flutter:
  assets:
    - assets/images/icon1.png
    - assets/images/icon2.png
    - assets/images/icon3.png
    - assets/images/icon4.png
    - assets/images/icon5.png

I hope this helps