它说:当我按照开发者网站上的说明进行操作时,“在pubspec.yaml文件的“ flutter”下找到了意外的孩子“ flutter””两次。我正在尝试向flutter项目中添加其他字体。
我尝试取出“ flutter:”代码,但随后仅显示另一个错误: pubspec.yaml的第60行第5列错误:解析块映射时需要键。
我还检查了pubspec.yaml文件中指定的字体文件是否正确。
网站链接:https://flutter.dev/docs/cookbook/design/fonts
提前谢谢!
name: greatapp
description: A new Flutter application.
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Futura
fonts:
- asset: fonts/Futura-Medium-01.ttf
- asset: fonts/Futura-MediumItalic-02.ttf
style: italic
我认为它只会集成字体,但是并没有,并且产生了我上面描述的错误。
答案 0 :(得分:1)
此文件中的间距为每个块应为2个单位。
fonts:
- family: Futura
fonts:
- asset: fonts/Futura-Medium-01.ttf
- asset: fonts/Futura-MediumItalic-02.ttf
style: italic
编辑:
name: greatapp
description: A new Flutter application.
environment:
sdk: ">=2.2.2 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Futura
fonts:
- asset: fonts/Futura-Medium-01.ttf
- asset: fonts/Futura-MediumItalic-02.ttf
style: italic