FlutterError: Unable to load asset

后端 未结 22 3359
死守一世寂寞
死守一世寂寞 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:16

    Flutter uses the pubspec.yaml file, located at the root of your project, to identify assets required by an app.

    Here is an example:

    flutter:
      assets:
        - assets/my_icon.png
        - assets/background.png
    

    To include all assets under a directory, specify the directory name with the / character at the end:

    flutter:
      assets:
        - directory/
        - directory/subdirectory/
    

    For more info, see https://flutter.dev/docs/development/ui/assets-and-images

提交回复
热议问题