SOLVED: I'm still not sure what the problem was, but I fixed it by simply creating a new Flutter project, getting the fonts set up in the new project, and then just pasting my .dart files into the new project. Even though everything was exactly the same (as far as I can tell) it worked fine. Go figure.
I'm trying to use custom fonts in my app without success.
This is the fonts section of my pubspec.yaml file:
fonts:
- family: Muli
fonts:
- asset: fonts/Muli-Light.ttf
- family: LibreBaskerville
fonts:
- asset: fonts/LibreBaskerville-Regular.ttf
And in my app:
Widget _sectionTitle(String text) {
return Container(
padding: EdgeInsets.fromLTRB(25.0, 0.0, 25.0, 5.0),
child: Text(text,
style: new TextStyle(fontFamily: 'Muli', fontSize: 50.0),
));
}
Widget _sectionText(String text){
return Container (
padding: EdgeInsets.fromLTRB(25.0, 0.0, 25.0, 15.0),
child: Text(text, style: TextStyle(fontFamily: 'LibreBaskerville', fontSize: 20.0)),
);
}
Among the things I've tried (multiple times):
I'm assuming there's something amiss with the pubspec.yaml file, but I can't see what it might be.
Any suggestions would be much appreciated. Thx.
EDIT: Just tried creating a new default Flutter app with the same Pubspec.yaml font info. I added the custom font to the MaterialApp widget and it works ... so maybe the problem is not the yaml.
Flutter Variable Font Support The Dart UI font feature class was for the font feature flags and any int values, but variable fonts requires double values. This is why currently, if you attempt to use variable fonts, specific styling does not appear applied.
remove the app from the test device then do flutter clean, re-run
flutter clean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With