微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

“使用材料设计:真实”不适用于 pubspec.yaml 中的其他资产

如何解决“使用材料设计:真实”不适用于 pubspec.yaml 中的其他资产

删除/评论此行之前,我无法向我的项目应用程序添加任何资源,例如图像、字体等

uses-material-design: true

错误

Error detected in pubspec.yaml:
Restarted application in ٨ms.
Error on line 25,column 4: Expected a key while parsing a block mapping.
   ╷
25 │    assets:
   │    ^
   ╵
Exception: Please correct the pubspec.yaml file at .\pubspec.yaml

除了这个问题,在pubspec.yaml中一切正常

name: mi_card
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  Flutter:
    sdk: Flutter

  cupertino_icons: ^0.1.2

dev_dependencies:
  Flutter_test:
    sdk: Flutter


Flutter:

  # The following line ensures that the Material Icons font is
  # included with your application,so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application,add an assets section,like this:
   assets:
    - images/

   fonts:
     - family: Pacifico
       fonts:
         - asset: fonts/Pacifico-Regular.ttf

     - family: Source Sans Pro
       fonts:
        - asset: fonts/SourceSanspro-Regular.ttf

但是因为我需要用到材质图标,所以需要和我的assets一起添加,那么如何解决这个问题?

解决方法

pubspec.yaml 对缩进敏感。

并且您在 uses-material-design: true 之后的 in 文件缩进一个空格,尝试将其删除,它会起作用。

复制并尝试:

name: mi_card
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter


flutter:

  # The following line ensures that the Material Icons font is
  # included with your application,so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

    # To add assets to your application,add an assets section,like this:
  assets:
    - images/

  fonts:
    - family: Pacifico
      fonts:
        - asset: fonts/Pacifico-Regular.ttf

    - family: Source Sans Pro
      fonts:
        - asset: fonts/SourceSansPro-Regular.ttf

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?