问题描述
我是 Flutter 的新手,仍然熟悉它的术语和属性。无论如何,当我使用 textTheme
并提及 title
、button
等任何属性时,它表明该属性已被弃用,不应再使用。我的假设是 textTheme
仅被弃用,那么我应该用什么替换它,以便它不被弃用?
解决方法
对于 title
,您需要改用 subtitle1
。
您可以在 text _theme.dart
中查看来自 TextTheme 源代码的弃用列表。如果您使用的是 IntelliJ,则可以通过右键单击 title
属性查看源代码,然后选择转到 -> 声明或用法。
此处是 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.'
)