我尝试在我的应用程序中添加一些字体,当我在pubsbec.yaml中添加它们时,它会发出"get软件包“,然后停止,没有结果。另外,当我试图添加另一个包时,也会发生同样的情况。另外一件事是,当我运行应用程序时,上面写着
Error detected in pubspec.yaml:
Error on line 66, column 4: Expected a key while parsing a block mapping.
╷
66 │ fonts:
│ ^
╵
Please correct the pubspec.yaml file注:我检查了空格和拼写,它们是真实的“我如何才能正确地做到这一点?”
公开文件的一部分
flutter:
uses-material-design: true
fonts:
- family: Ranga
fonts:
- asset: fonts/Ranga-Regular.ttf
- asset: fonts/Ranga-Bold.ttf
style: Bold
weight: 700我就是这样使用字体的:
Text("Recipe Name",
style: TextStyle(
color: Colors.black54,
fontSize: 30,
fontWeight: FontWeight.w700,
fontFamily: "Ranga"
),发布于 2020-11-05 14:36:57
检查空格,它们在.yaml文件中很重要。其结果应该像下面的图像:

https://stackoverflow.com/questions/64687312
复制相似问题