抖动错误资产:图像资源服务引起的异常

时间:2020-05-05 08:23:04

标签: flutter dart

未正确显示所有路径,因此无法显示图像。 您可以看到代码。enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

2 个答案:

答案 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

我希望这会有所帮助