[英]Flutter setting default font family for non-material apps
I want to use a default font family for my flutter app but according to the Flutter docs for setting a default font family we should declare it as a theme data in our MaterialApp instance我想为我的 flutter 应用程序使用默认字体系列,但根据Flutter 文档设置默认字体系列,我们应该在 MaterialApp 实例中将其声明为主题数据
Text : To use a font as the default, set the fontFamily property as part of the app's theme.
Text :要将字体用作默认字体,请将 fontFamily 属性设置为应用程序主题的一部分。 The value provided to fontFamily must match the family name declared in the pubspec.yaml.
提供给 fontFamily 的值必须与 pubspec.yaml 中声明的系列名称相匹配。
MaterialApp(
title: 'Custom Fonts',
// Set Raleway as the default app font.
theme: ThemeData(fontFamily: 'Raleway'),
home: MyHomePage(),
);
But I don't want to use MaterialApp for my app and I want to set a font as the default font of my application, any solution?但是我不想为我的应用程序使用 MaterialApp,我想将一种字体设置为我的应用程序的默认字体,有什么解决方案吗?
No. you can use your font anywhere that you want不,你可以在任何你想要的地方使用你的字体
Text("Helloo!",style:TextStyle(fontFamily:"font name"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.