3

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?

3 Answers3

8

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
1

The issue was coming up with me. please recheck all lines in your pubspec.yaml file. it's spaces issue.

0

try removing the {:} colon in the fonts directory and write

fonts:
 - family: SairaSemiCondensed
   fonts:
     - asset: fonts/SairaSemiCondensed-Bold.ttf
       weight: 700 # indented more

INSTEAD

elarcoiris
  • 1,914
  • 4
  • 28
  • 30