【发布时间】:2021-05-18 15:21:54
【问题描述】:
我正在尝试通过 pubsec.yaml 中的资产添加图像,但它一直给我以下错误:
pubsec.yaml 代码:
name: grid_project
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
assets:
- assets/bus.png
- assets/circle.png
- assets/info.png
- assets/phone.png
- assets/play.png
- assets/square.png
uses-material-design: true
问题出现在flutter 下方的assets 字上,错误提示“'asset' 字段的值应该是相对文件路径的列表。
尝试将值转换为相对文件路径的列表。dart(asset_field_not_list)"
【问题讨论】:
-
嗯,我觉得不错。您确定错误来自 pubspec.yaml 文件而不是其他地方的代码吗?另外,您在项目中的文件结构是什么(您将资产保存在哪里)?
-
我确信错误来自 pubsec.yaml 文件,在输出选项卡中它给了我这个“在 pubspec 中检测到错误。”。这些图像位于项目根文件夹中名为 assets 的文件夹中。