【问题标题】:giving this error when I am using assets in flutter vs code assets: - assets/images/当我在颤振与代码资产中使用资产时出现此错误:-资产/图像/
【发布时间】:2020-11-22 08:27:49
【问题描述】:

当我在颤振与代码资产中使用资产时出现此错误:-资产/图像/

[demo] flutter pub get
Error detected in pubspec.yaml:
Error on line 51, column 4: Expected a key while parsing a block mapping.
   ╷
51 │    assets:
   │    ^
   ╵
Please correct the pubspec.yaml file at D:\Flutter\demo\pubspec.yaml
exit code 1

【问题讨论】:

  • 给我 pubspec.yaml 的截图,
  • 添加您的 pubspec.yaml 文件截图或代码 看起来您在assets:之后没有添加新行
  • assets: - assets/images/ # - images/a_dot_ham.jpeg

标签: flutter


【解决方案1】:

我猜你的 pubspec.yaml 文件中有一些语法错误。

下面是关于资产部分应该如何在 pubspec.yaml 文件中提及的 sn-p。

flutter:
  # To add assets to your application, add an assets section, like this:
   assets:
    - images/a_dot_burr.jpeg
    - images/a_dot_ham.jpeg

现在需要将 images 文件夹放在您的主目录中,而不是放在 lib 文件夹中。

希望它能解决你的问题。

【讨论】:

    【解决方案2】:

    Pubspec.yaml 区分大小写,需要注意间距。

    没有空间给父级 2 给孩子的空间 给孙子多出 2 个空间

    希望你能理解

    【讨论】:

    • assets: - assets/images/ # - images/a_dot_ham.jpeg
    猜你喜欢
    • 2021-11-24
    • 1970-01-01
    • 2019-03-09
    • 2019-12-14
    • 2020-01-04
    • 2023-01-11
    • 2017-06-16
    • 2021-09-28
    • 1970-01-01
    相关资源
    最近更新 更多