ThemeData-不建议使用的标题参数

时间:2020-04-19 22:32:24

标签: flutter dart

我试图找到以下问题的答案:“如何正确编码ThemeData已贬值的'title'参数? (我正在学习教程)。但是,我在其他主题的一些评论中找到了正确的答案。我将答案留在下面,以供将来参考和轻松查找。

theme: new ThemeData(
  primaryTextTheme: TextTheme(
      title: TextStyle(
color: Colors.white,
))),

How to change text color of AppBar, icon color of FAB universally using theme?

eMarine的回答:https://stackoverflow.com/users/1584407/emarine

2 个答案:

答案 0 :(得分:5)

将“标题”替换为“ headline6”:

theme: new ThemeData(
  primaryTextTheme: TextTheme(
      headline6: TextStyle(
color: Colors.white,
))),

答案 1 :(得分:1)

现在已弃用,该提示信息本身说明了使用方法

'title是2014版材料设计中使用的术语。的 现代术语是headline6。 ' “ v1.13.8之后不推荐使用此功能。”

示例:

ThemeData(
          textTheme: ThemeData.light().textTheme.copyWith(
                headline6: GoogleFonts.lato(
                    color: _customColor,
                    fontWeight: FontWeight.normal),
              ),
      ),

类似地,

其他参数也被描述,因此我们现在必须使用下面提到的正确参数

display4 => headline1;
display3 => headline2;
display2 => headline3;
display1 => headline4;
headline => headline5;
title => headline6;