I am a newbie in Flutter, and still getting familiar with terms and properties of it. Anyways, when I am using textTheme
, and mention any property like title
, button
etc. it shows that the property is deprecated and shouldn't be used anymore. My assumption is textTheme
is only deprecated, so what should I replace it with, so that it is not deprecated?
For title
, you need to use subtitle1
instead.
You can see the deprecated list from TextTheme source code in text _theme.dart
. If you're using IntelliJ, you can view the source code by right-clicking the title
property, then select Go To -> Declaration or Usages .
Here the excerpts for deprecated properties of 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.'
)
textTheme is deprecated and shouldn't be used. This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. This feature was deprecated after v2.4.0-0.0.pre.
Solution
Use 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)),
Following ישו אוהב אותך's answer, and reading properly the documentation he or she kindly shared, you need to substitute title by headline6 , not subtitle1.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.