MaterialStateTextStyle typedef

  1. @Deprecated('Use WidgetStateTextStyle instead. ' 'Moved to the Widgets layer to make code available outside of Material. ' 'This feature was deprecated after v3.19.0-0.3.pre.')
MaterialStateTextStyle = WidgetStateTextStyle

Defines a TextStyle that is also a MaterialStateProperty.

This class exists to enable widgets with TextStyle valued properties to also accept MaterialStateProperty<TextStyle> values. A material state text style property represents a text style which depends on a widget's "interactive state". This state is represented as a Set of MaterialStates, like MaterialState.pressed, MaterialState.focused and MaterialState.hovered.

MaterialStateTextStyle should only be used with widgets that document their support, like InputDecoration.labelStyle.

To use a MaterialStateTextStyle, you can either:

  1. Create a subclass of MaterialStateTextStyle and implement the abstract resolve method.
  2. Use MaterialStateTextStyle.resolveWith and pass in a callback that will be used to resolve the color in the given states.

If a MaterialStateTextStyle is used for a property or a parameter that doesn't support resolving MaterialStateProperty<TextStyle>s, then its default color value will be used for all states.

To define a const MaterialStateTextStyle, you'll need to extend MaterialStateTextStyle and override its resolve method. You'll also need to provide a defaultValue to the super constructor, so that we can know at compile-time what its default color is.

See also:

  • WidgetStateTextStyle, the non-Material version that can be used interchangeably with MaterialStateTextStyle.

Implementation

@Deprecated(
  'Use WidgetStateTextStyle instead. '
  'Moved to the Widgets layer to make code available outside of Material. '
  'This feature was deprecated after v3.19.0-0.3.pre.'
)
typedef MaterialStateTextStyle = WidgetStateTextStyle;