Flutter上的自定义字体 [英] Custom Font on Flutter
本文介绍了Flutter上的自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Flutter上自定义字体时遇到了问题
I have problem when I custom font on Flutter
我的文件夹字体
myapp/fonts/SairaSemiCondensed-Bold.ttf
myapp/fonts/SairaSemiCondensed-Bold.ttf
这是我的pubspec.ymal
here my pubspec.ymal
fonts:
- family: SairaSemiCondensed
fonts:
- asset: fonts/fonts:SairaSemiCondensed-Bold.ttf
weight: 700
我遇到这样的错误
Error on line 55, column 4 of pubspec.yaml: Expected a key while parsing a
block mapping.
fonts:
^
pub get failed (65)
有人可以帮助我吗?
推荐答案
尝试
fonts:
- family: SairaSemiCondensed
fonts:
- asset: fonts/fonts:SairaSemiCondensed-Bold.ttf
weight: 700 # indented more
,但是整个块的缩进更有可能是错误的(或丢失).尝试使问题中的所有行缩进一个标签或两个空格.
but it's more likely that the indentation of the whole block is wrong (or missing). Try to indent all lines in your questions one tab or 2 spaces more.
缩进以yaml表示.
Indentation is significant in yaml.
尝试完全遵循 https://flutter.io/docs/cookbook/中所示的缩进设计/字体,如果我的上述建议无效.
Try to follow indentation exactly as shown in https://flutter.io/docs/cookbook/design/fonts if my suggestion above doesn't work.
这篇关于Flutter上的自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文