Reputation: 1779
For adding custom font style in pubspec.yaml gives
Error detected in pubspec.yaml:
Invalid value Bold ((String)) for font -> style.
Please correct the pubspec.yaml file at /Users/directory/pubspec.yaml
here is the code in pubspec.yaml
fonts:
- family: Gilroy
fonts:
- asset: fonts/gilroy_bold.ttf
style: Bold
- asset: fonts/gilroy_bolditalic.ttf
weight: 900
- asset: fonts/gilroy_medium.ttf
weight: 700
Upvotes: 3
Views: 4538
Reputation: 61
The reason why style: bold
does not work is because there is only two constants in Flutter > dart:ui > FontStyle enum, which are:
italic → const FontStyle
normal → const FontStyle
values → const List<FontStyle>
Check: https://api.flutter.dev/flutter/dart-ui/FontStyle.html
Upvotes: 4
Reputation: 1458
You want this.
fonts:
- family: Gilroy
fonts:
- asset: fonts/gilroy_bold.ttf
weight: 700
- asset: fonts/gilroy_bolditalic.ttf
weight: 700
style: italic
- asset: fonts/gilroy_medium.ttf
weight: 500
Upvotes: 5
Reputation: 331
fonts:
- family: Gilroy
fonts:
- asset: fonts/gilroy_bold.ttf
weight: <your_desired_value> (But must be between 100 to 900)
- asset: fonts/gilroy_bolditalic.ttf
weight: 900
- asset: fonts/gilroy_medium.ttf
weight: 700
Upvotes: 0