我的pubspec.yaml文件中出现以下异常:
Error detected in pubspec.yaml:
Expected "assets" to be a list, but got -assets/image/ (String).
Please correct the pubspec.yaml file at D:\Working_Project\FlutterProject\flutter_change_color\pubspec.yaml发布于 2020-05-24 21:47:14
我也犯了同样的错误,我认为您必须像下面这样添加资产:
Flutter使用位于项目根目录的'pubspec.yaml‘文件来识别应用程序所需的资源。下面是一个示例:
flutter:
assets:
- assets/my_icon.png
- assets/background.png要包含某个目录下的所有资源,请在目录名称的末尾加上/字符:
assets:
- directory/
- directory/subdirectory/现在让我们来看看你的错误
期望"assets“是一个列表,但得到了-assets/image/ (String)。
出现此错误的原因是您没有在"- and assets“之间添加空格。如果你只是添加空间,它应该可以解决你的问题。
发布于 2020-08-20 01:32:59
在pubspec.yaml文件中使用正确的格式非常重要。使用:
assets:
- assets/images(字符串-和assets/images之间必须有空格)
发布于 2021-01-24 02:18:09
你需要在破折号(-)和“资产”之间留一个空格。
- assets/image/https://stackoverflow.com/questions/61303506
复制相似问题