Skip to main content

MaterialStateProperty

Type Alias MaterialStateProperty 

Source
pub type MaterialStateProperty<T> = dyn WidgetStateProperty<T>;
👎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.

Expand description

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 WidgetState::Focused, WidgetState::Hovered, WidgetState::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 is the erased property, dyn WidgetStateProperty<T>: Dart’s static members are reached through it (<MaterialStateProperty<Color>>::resolve_with(..)), and a type implements WidgetStateProperty itself.

See also:

  • WidgetStateProperty, the non-Material version that can be used interchangeably with MaterialStateProperty.