在删除/注释此行之前,我无法将任何资产(如图像、字体等(添加到我的项目应用程序中
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
但因为我需要使用材质图标,我需要将其与我的资产一起添加,所以如何解决这个问题?
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