Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Font on Flutter

Tags:

flutter

native

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?

like image 848
rizky Zulkarnaen Avatar asked Mar 19 '26 18:03

rizky Zulkarnaen


1 Answers

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.

like image 65
Günter Zöchbauer Avatar answered Mar 21 '26 08:03

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!