简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM