use*_*307 6 fonts flutter google-fonts
我是扑的新手。
我安装了这个库以便能够使用谷歌字体。
现在我需要在主题数据定义中这样做,并尝试这样但不允许
ThemeData appTheme() {
return ThemeData(
...
fontFamily: GoogleFonts.openSans(),
);
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?非常感谢
Ume*_*qas 10
在main.dart
文件中添加
fontFamily: GoogleFonts.poppins().fontFamily,
Run Code Online (Sandbox Code Playgroud)
将下面的代码粘贴到您的主题文件中,并将其添加到您的 ThemeData(textTheme: textTheme)
final TextTheme textTheme = TextTheme(
headline1: GoogleFonts.roboto(
fontSize: 97, fontWeight: FontWeight.w300, letterSpacing: -1.5),
headline2: GoogleFonts.roboto(
fontSize: 61, fontWeight: FontWeight.w300, letterSpacing: -0.5),
headline3: GoogleFonts.roboto(fontSize: 48, fontWeight: FontWeight.w400),
headline4: GoogleFonts.roboto(
fontSize: 34, fontWeight: FontWeight.w400, letterSpacing: 0.25),
headline5: GoogleFonts.roboto(fontSize: 24, fontWeight: FontWeight.w400),
headline6: GoogleFonts.roboto(
fontSize: 20, fontWeight: FontWeight.w500, letterSpacing: 0.15),
subtitle1: GoogleFonts.roboto(
fontSize: 16, fontWeight: FontWeight.w400, letterSpacing: 0.15),
subtitle2: GoogleFonts.roboto(
fontSize: 14, fontWeight: FontWeight.w500, letterSpacing: 0.1),
bodyText1: GoogleFonts.roboto(
fontSize: 16, fontWeight: FontWeight.w400, letterSpacing: 0.5),
bodyText2: GoogleFonts.roboto(
fontSize: 14, fontWeight: FontWeight.w400, letterSpacing: 0.25),
button: GoogleFonts.roboto(
fontSize: 14, fontWeight: FontWeight.w500, letterSpacing: 1.25),
caption: GoogleFonts.roboto(
fontSize: 12, fontWeight: FontWeight.w400, letterSpacing: 0.4),
overline: GoogleFonts.roboto(
fontSize: 10, fontWeight: FontWeight.w400, letterSpacing: 1.5),
);
Run Code Online (Sandbox Code Playgroud)
该视频很好地解释了如何在 flutter 中使用主题和字体https://youtu.be/stoJpMeS5aY?t=640
归档时间: |
|
查看次数: |
2596 次 |
最近记录: |