Invalid value style ((String)) for font -> style in Flutter

Viewed 2248

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
3 Answers

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
    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
Related