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

Time:12-14

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 :)

CodePudding user response:

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')
  • Related