MaterialStateProperty<T> typedef

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

Interface for classes that resolve to a value of type T based on a widget's interactive "state", which is defined as a set of MaterialStates.

Material state properties represent values that depend on a widget's material "state". The state is encoded as a set of MaterialState values, like MaterialState.focused, MaterialState.hovered, MaterialState.pressed. For example the InkWell.overlayColor defines the color that fills the ink well when it's pressed (the "splash color"), focused, or hovered. The InkWell uses the overlay color's resolve method to compute the color for the ink well's current state.

ButtonStyle, which is used to configure the appearance of buttons like TextButton, ElevatedButton, and OutlinedButton, has many material state properties. The button widgets keep track of their current material state and resolve the button style's material state properties when their value is needed.

This example shows how you can override the default text and icon color (the "foreground color") of a TextButton with a MaterialStateProperty. In this example, the button's text color will be Colors.blue when the button is being pressed, hovered, or focused. Otherwise, the text color will be Colors.red.
link

To create a local project with this code sample, run:
flutter create --sample=material.MaterialStateProperty.1 mysample

See also:

Implementation

@Deprecated(
  'Use WidgetStateProperty 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 MaterialStateProperty<T> = WidgetStateProperty<T>;