微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

替换颤振中已弃用的 textTheme

如何解决替换颤振中已弃用的 textTheme

我是 Flutter 的新手,仍然熟悉它的术语和属性。无论如何,当我使用 textTheme 并提及 titlebutton 等任何属性时,它表明该属性已被弃用,不应再使用。我的假设是 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.'
)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。