Hus*_*awi 20 fonts themes flutter
如何更改应用程序的每个文本以使用特定字体?我可以使用 单独更改它们,TextStyle()
但如何使我的应用程序默认为特定字体?你能告诉我怎么做吗?
mah*_*mnj 54
如果您想使用其中一种Google 字体,请使用材料团队提供的官方google_fonts包。
dependencies:
google_fonts: ^2.1.0
Run Code Online (Sandbox Code Playgroud)
MaterialApp(
theme: ThemeData(
textTheme: GoogleFonts.latoTextTheme(
Theme.of(context).textTheme,
),
),
);
Run Code Online (Sandbox Code Playgroud)
OMi*_*hah 34
您可以按照以下步骤更改 Flutter 应用程序的默认字体系列:
1. 将您的字体文件添加到您的项目文件夹中。说Project Folder > assets > fonts > hind
。
2.在您的项目文件中使用带有样式的字体文件声明字体系列pubspec.yaml
(示例):
MaterialApp
主类文件的小部件中,将默认字体系列定义为:Roh*_*ora 12
将谷歌字体添加到 pubspec.yaml
dependencies:
google_fonts: ^2.1.0
Run Code Online (Sandbox Code Playgroud)
使用 fontFamily 函数
MaterialApp(
theme: ThemeData(
fontFamily: GoogleFonts.lato().fontFamily,
),
);
Run Code Online (Sandbox Code Playgroud)
记得导入谷歌字体
import 'package:google_fonts/google_fonts.dart';
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23075 次 |
最近记录: |