body2 已弃用,不应使用。这是2014年版材料设计中使用的术语。- 颤振中的警告消息



如果您将flutter SDK从v1.1213版本更新到V113.8之后的任何版本,您将收到几个与textTheme使用相关的警告消息。例如,下面给出的其中一个。

info:body2已弃用,不应使用。这是2014版材料设计中使用的术语。现代术语是bodyText1。此功能在v1.13.8之后已被弃用。.

新版本有什么变化?如何迁移?

材料规范2014的文本主题和材料规范2018的文本主题有什么区别

TextThemeAPI最初基于原始材料(2014(设计规范,其中使用了不同的文本样式名称。

下面给出了这两个值。

2018规格-文本样式

NAME         SIZE  WEIGHT  SPACING
headline1    96.0  light   -1.5
headline2    60.0  light   -0.5
headline3    48.0  regular  0.0
headline4    34.0  regular  0.25
headline5    24.0  regular  0.0
headline6    20.0  medium   0.15
subtitle1    16.0  regular  0.15
subtitle2    14.0  medium   0.1
body1        16.0  medium   0.5   (bodyText1)
body2        14.0  regular  0.25  (bodyText2)
button       14.0  medium   1.25
caption      12.0  regular  0.4
overline     10.0  regular  1.5

2014规格-文本样式

NAME       SIZE   WEIGHT   SPACING  2018 NAME
display4   112.0  thin     0.0      headline1
display3   56.0   normal   0.0      headline2
display2   45.0   normal   0.0      headline3
display1   34.0   normal   0.0      headline4
headline   24.0   normal   0.0      headline5
title      20.0   medium   0.0      headline6
subhead    16.0   normal   0.0      subtitle1
body2      14.0   medium   0.0      body1 (bodyText1)
body1      14.0   normal   0.0      body2 (bodyText2)
caption    12.0   normal   0.0      caption
button     14.0   medium   0.0      button
subtitle   14.0   medium   0.0      subtitle2
overline   10.0   normal   0.0      overline

如何使用新的TextTheme属性?(颤振v1.13.8及以上版本(

您可以使用所需的属性,如下所示。

Theme.of(context).textTheme.headline1
Theme.of(context).textTheme.headline2
Theme.of(context).textTheme.headline3
Theme.of(context).textTheme.headline4
Theme.of(context).textTheme.headline5
Theme.of(context).textTheme.headline6
Theme.of(context).textTheme.subtitle1
Theme.of(context).textTheme.subtitle2
Theme.of(context).textTheme.body1
Theme.of(context).textTheme.body2
Theme.of(context).textTheme.button
Theme.of(context).textTheme.caption
Theme.of(context).textTheme.overline

哪些属性名称没有更改

只有以下两个属性名称在两个Theme类中是通用的。

Theme.of(context).textTheme.caption
Theme.of(context).textTheme.overline

最新更新