如何解决“使用材料设计:真实”不适用于 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 举报,一经查实,本站将立刻删除。