Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter “预期”;“资产”;要成为一个列表,但得到-资产/图像/(字符串)_Flutter_Yaml - Fatal编程技术网

Flutter “预期”;“资产”;要成为一个列表,但得到-资产/图像/(字符串)

Flutter “预期”;“资产”;要成为一个列表,但得到-资产/图像/(字符串),flutter,yaml,Flutter,Yaml,我在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 在PUBSPEC.YAML中 #要向应

我在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
在PUBSPEC.YAML中 #要向应用程序添加资产,请添加资产部分,如下所示: 资产:

而不是
{-assets/image/image name}

使用


{-assets/image/image name}

我遇到了相同的错误,我发现您必须添加如下资产:

Flatter使用位于项目根目录下的“pubspec.yaml”文件来识别应用程序所需的资产。 以下是一个例子:

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

要包括目录下的所有资产,请指定目录名称,并在末尾使用/字符:

  assets:
    - directory/
    - directory/subdirectory/
现在让我们来谈谈你的错误

预期“资产”是一个列表,但得到了-assets/image/(字符串)。


发生此错误是因为您没有在“-和资产”之间添加空格。如果你只是增加空间,它应该可以解决你的问题

使用材料设计:正确

#要向应用程序添加资产,请添加资产部分,如下所示: 资产: -图像/pic.jpeg -图像/pic1.jpeg

对齐使用材质设计:真实和资产:至边缘 然后振作起来
然后在方括号内写下你的资产清单

  assets: [-assets/example.png]

在pubspec.yaml文件中使用正确的格式非常重要。 使用:


(字符串
-
资产/图像之间需要空格)

您需要在破折号(-)和“资产”之间留出空格


颤振返回此错误,因为输入格式不正确

正确的格式如下

flutter:
 assets:
  -folder/file.png

请在此处共享您的pubspec.yaml文件。建议您提供更多上下文
- assets/image/
flutter:
 assets:
  -folder/file.png