FlutterError: Unable to load asset

后端 未结 22 3272
死守一世寂寞
死守一世寂寞 2020-11-30 10:31

This is the folder structure of my app

.idea
.vscode
android
build
fonts
 Oxygen-Bold.tff
 Oxygen-Light.tff
 Oxygen-Regular.tff
images
 pizza0.png
 pizza1.pn         


        
相关标签:
22条回答
  • 2020-11-30 11:17

    I haved a similar problem, I fixed here:

    uses-material-design: true
     assets:
       - assets/images/
    

    After, do:

    Flutter Clean
    
    0 讨论(0)
  • 2020-11-30 11:17

    Make sure the file names do not contain special characters such as ñ for example

    0 讨论(0)
  • 2020-11-30 11:20

    This is issue has almost driven me nut in the past. To buttress what others have said, after making sure that all the indentations on the yaml file has been corrected and the problem persist, run a 'flutter clean' command at the terminal in Android studio. As at flutter 1.9, this should fix the issue.

    0 讨论(0)
  • 2020-11-30 11:21

    Dec 25th, 2019 :

    Whoever facing issue regarding Image not showing in Flutter , let me give you simple checkpoints :

    1. Image.asset('assets/images/photo1.png'); -- here make sure dont use / (forward slash ) before assets.
    2. YAML file always be clear dont use space , instead use TAB.
    3. YAML file add entries for assets. as mentioned in above comment.

    First point is very important

    0 讨论(0)
  • 2020-11-30 11:21

    Please provide the exact image name(including the extension) as specified in the images folder. A mismatch can trigger this exception.

    0 讨论(0)
  • 2020-11-30 11:25

    While I was loading a new image in my asset folder, I just encountered the problem every time.

    I run flutter clean & then restarted the Android Studio. Seems like flutter packages caches the asset folder and there is no mechanism to update the cache when a developer adds a new image in the project (Personal thoughts).

    0 讨论(0)
提交回复
热议问题