我是一个初来乍到的新手,对它的术语和特性仍然很熟悉。无论如何,当我使用textTheme
,并提到任何属性,如title
、button
等,都会显示出该属性已经过时,不应该再使用了。我的假设是,textTheme
只被弃用,所以我应该用什么来代替它,这样它就不会被废弃了?
发布于 2021-02-19 19:26:16
对于title
,您需要使用subtitle1
代替。
您可以在TextTheme源代码中看到text _theme.dart
中的不推荐列表。如果您使用的是IntelliJ,您可以通过右键单击title
属性查看源代码,然后选择Go To -> 声明或Usage。
这里摘录了text _theme.dart
的不推荐属性
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is headline1. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? display4,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is headline2. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? display3,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is headline3. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? display2,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is headline4. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? display1,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is headline5. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? headline,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is headline6. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? title,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is subtitle1. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? subhead,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is subtitle2. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? subtitle,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is bodyText1. '
'This feature was deprecated after v1.13.8.'
)
TextStyle? body2,
@Deprecated(
'This is the term used in the 2014 version of material design. The modern term is bodyText2. '
'This feature was deprecated after v1.13.8.'
)
发布于 2022-05-22 05:59:23
不建议使用
textTheme,不应该使用它。此属性不再使用,请改用toolbarTextStyle和titleTextStyle。这个特性在v2.4.0-0.PRE之后就被否决了。溶液
使用toolbarTextStyle
appBarTheme: AppBarTheme(
color: Colors.white,
elevation: 0.0,
iconTheme: IconThemeData(color: Colors.black),
toolbarTextStyle: Theme.of(context).textTheme.bodyText2,
titleTextStyle: Theme.of(context).textTheme.headline6)),
发布于 2022-04-02 07:28:17
按照的回答,并正确阅读他或她友好共享的文档,您需要用headline6而不是subtitle1代替ישואוהבאותך标题。
https://stackoverflow.com/questions/66287632
复制