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.bluewhen the button is being pressed, hovered, or focused. Otherwise, the text color will be
flutter create --sample=material.MaterialStateProperty.1 mysample
- MaterialStateColor, a Color that implements
MaterialStatePropertywhich is used in APIs that need to accept either a Color or a
- MaterialStateMouseCursor, a MouseCursor that implements
MaterialStatePropertywhich is used in APIs that need to accept either a MouseCursor or a MaterialStateProperty<MouseCursor>.
T>( T value) → MaterialStateProperty< T>
- Convenience method for creating a MaterialStateProperty that resolves to a single value for all states.
T>( T value, Set< MaterialState>states) → T
Resolves the value for the given set of states if
valueis a MaterialStateProperty, otherwise returns the value itself. [...]
T>( MaterialPropertyResolver< T>callback) → MaterialStateProperty< T>
- Convenience method for creating a MaterialStateProperty from a MaterialPropertyResolver function alone.