答案 0 :(得分:2)
问题是由于缩进造成的。尝试使用重新设置pubspec文件的格式,它将正常运行。
请尝试以下示例
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
图像的*破折号(-)必须位于资产的第二个“ s”之下。
答案 1 :(得分:1)
收到错误消息是因为pubspec.yalm
文件中的缩进错误。
尝试更正缩进。使用以下代码: 效果很好。
flutter:
assets:
- assets/images/icon1.png
- assets/images/icon2.png
- assets/images/icon3.png
- assets/images/icon4.png
- assets/images/icon5.png
我希望这会有所帮助