简体   繁体   English

使用预制的 flutter 主题时如何设置默认字体系列?

[英]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.我正在尝试为我的 Flutter 应用程序设置默认字体。 I've read all the documentation and followed it, however, the docs say to use theme: ThemeData(fontFamily: 'Example'), .我已经阅读了所有文档并遵循了它,但是,文档说要使用theme: ThemeData(fontFamily: 'Example'), The issue I have is that I'm using theme: ThemeData.light(), not theme: ThemeData(), .我遇到的问题是我使用的是theme: ThemeData.light(),而不是theme: ThemeData(), Putting the fontFamily: 'Example' in the brackets after .light() doesn't work.fontFamily: 'Example'放在.light()之后的括号中不起作用。

So my question is, how do you set the default font for this pre-made flutter theme?所以我的问题是,如何为这个预制的 flutter 主题设置默认字体?

Thanks in advance:)提前致谢:)

The implementation of ThemeData.light() (what it acutally is doing) says here : ThemeData.light() 的实现(它实际上在做什么) 在这里说:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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