如何在Flutter中定义主题时使用Google字体 [英] How do I use google fonts on defining a theme in flutter

查看:809
本文介绍了如何在Flutter中定义主题时使用Google字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的人.

我安装了库,以便能够使用Google字体.

I installed this library to be able to use google fonts.

现在我需要在主题数据定义中执行此操作,并尝试这样操作,但不允许这样做

Now I need to do it in the theme data definition, and tried like this but it's not allowed

ThemeData appTheme() {
  return ThemeData(
    ...
    fontFamily: GoogleFonts.openSans(),
  );
}

我该怎么做?非常感谢

推荐答案

重新发布我的评论:fontFamily期望为String.使用GoogleFonts.openSans().fontFamily.

Reposting my comment: fontFamily expects a String. Use GoogleFonts.openSans().fontFamily.

这篇关于如何在Flutter中定义主题时使用Google字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆