Replacement of deprecated textTheme in flutter

Issue

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?

Solution

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.'
)

Answered By – ישו אוהב אותך

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.