MaterialStateProperty<T> typedef
- @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.')
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.
Colors.blue
when the button is being pressed, hovered,
or focused. Otherwise, the text color will be Colors.red
.
To create a local project with this code sample, run:
flutter create --sample=material.MaterialStateProperty.1 mysample
See also:
- WidgetStateProperty, the non-Material version that can be used
interchangeably with
MaterialStateProperty
. - MaterialStateColor, a Color that implements
MaterialStateProperty
which is used in APIs that need to accept either a Color or aMaterialStateProperty<Color>
. - MaterialStateMouseCursor, a MouseCursor that implements
MaterialStateProperty
which is used in APIs that need to accept either a MouseCursor or a MaterialStateProperty<MouseCursor>. - MaterialStateOutlinedBorder, an OutlinedBorder that implements
MaterialStateProperty
which is used in APIs that need to accept either an OutlinedBorder or a MaterialStateProperty<OutlinedBorder>. - MaterialStateOutlineInputBorder, an OutlineInputBorder that implements
MaterialStateProperty
which is used in APIs that need to accept either an OutlineInputBorder or a MaterialStateProperty<OutlineInputBorder>. - MaterialStateUnderlineInputBorder, an UnderlineInputBorder that implements
MaterialStateProperty
which is used in APIs that need to accept either an UnderlineInputBorder or a MaterialStateProperty<UnderlineInputBorder>. - MaterialStateBorderSide, a BorderSide that implements
MaterialStateProperty
which is used in APIs that need to accept either a BorderSide or a MaterialStateProperty<BorderSide>. - MaterialStateTextStyle, a TextStyle that implements
MaterialStateProperty
which is used in APIs that need to accept either a TextStyle or a MaterialStateProperty<TextStyle>.
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>;