Reputation: 53
I have problem when I custom font on Flutter
My folder font
myapp/fonts/SairaSemiCondensed-Bold.ttf
here my pubspec.ymal
fonts:
- family: SairaSemiCondensed
fonts:
- asset: fonts/fonts:SairaSemiCondensed-Bold.ttf
weight: 700
I got error like this
Error on line 55, column 4 of pubspec.yaml: Expected a key while parsing a
block mapping.
fonts:
^
pub get failed (65)
Can anyone help me?
Upvotes: 3
Views: 2734
Reputation: 193
The issue was coming up with me.
please recheck all lines in your pubspec.yaml
file. it's spaces issue.
Upvotes: 1
Reputation: 1
try removing the {:} colon in the fonts directory and write
fonts:
- family: SairaSemiCondensed
fonts:
- asset: fonts/SairaSemiCondensed-Bold.ttf
weight: 700 # indented more
INSTEAD
Upvotes: 0
Reputation: 657158
Try
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.
Indentation is significant in yaml.
Try to follow indentation exactly as shown in https://flutter.io/docs/cookbook/design/fonts if my suggestion above doesn't work.
Upvotes: 8