Flutter - Custom Font not displaying

前端 未结 12 2094
感动是毒
感动是毒 2021-01-03 20:11

This is an excerpt of my pubspec.yaml file:

flutter:
  uses-material-design: true
  fonts:
   - family: Coiny
     fonts:
       - asset: fonts/Coiny-Regular         


        
12条回答
  •  醉梦人生
    2021-01-03 20:48

    I had an issue with the font and was receiving these two warnings:

    Warning: No fonts specified for font [font family name]
    Warning: Missing family name for font.
    

    The issue was that I had the pubspec.yaml fonts section typed incorrectly.

    Make sure your pubspec.yaml looks like this:

    flutter:
    
      fonts:
        - family: FontFamily
          fonts:
          - asset: fonts/Font-Medium.ttf
    
      uses-material-design: true
    

    You will then need to flutter clean and then flutter pub get. If all of this fails, try to uninstall the app and then reinstall it again (as Collin states above) after doing the above.

    I had a "-" next to the nested fonts declaration, which was causing those errors (and the font not to work).

提交回复
热议问题