This is an excerpt of my pubspec.yaml file:
flutter:
uses-material-design: true
fonts:
- family: Coiny
fonts:
- asset: fonts/Coiny-Regular
Font declaration alignment is not as per flutter pubspec.yaml. It should be like below.
fonts:
- family: Coiny
fonts:
- asset: fonts/Coiny-Regular.ttf
You can check out it here.
I had font:
not right under flutter:
. I moved the font:
section right under flutter:
, and worked.
flutter:
fonts:
- family: Test
fonts:
- asset: assets/fonts/Font-Test.ttf
Whenever you make changes to pubspec.yaml
file, it is always a good idea to stop the ongoing dart process from your IDE and do a full restart.
If you do hot reload or hot restart, engine may not be able to fetch the newly added data to your file. If nothing works, you should use @Collin answer, uninstall and reinstall the app.
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).
set in pubspec.yaml
fonts:
- family: Montserrat
fonts:
- asset: assets/fonts/Montserrat-Regular.ttf
- asset: assets/fonts/Montserrat-Bold.ttf
and then make sure that clean and build
You have add new files in the app therefore you have to close the running device and then restart the emulator.
-stop a running emulator -run a emulator
It works in my case.