Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you set a default font family when using a pre-made flutter theme?

I am trying to set the default font for my Flutter app. I’ve read all the documentation and followed it, however, the docs say to use theme: ThemeData(fontFamily: 'Example'),. The issue I have is that I’m using theme: ThemeData.light(), not theme: ThemeData(),. Putting the fontFamily: 'Example' in the brackets after .light() doesn’t work.

So my question is, how do you set the default font for this pre-made flutter theme?

Thanks in advance 🙂

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The implementation of ThemeData.light() (what it acutally is doing) says here:

factory ThemeData.light() => ThemeData(brightness: Brightness.light);

So you could achieve the light theme with the font of your choice with:

ThemeData(brightness: Brightness.light, fontFamily: 'Example')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading