WidgetStateProperty<T> class
abstract
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 WidgetStates.
Widget state properties represent values that depend on a widget's "state". The state is encoded as a set of WidgetState 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.
See also:
- MaterialStateProperty, the Material specific version of
WidgetStateProperty
. - WidgetStateColor, a Color that implements
WidgetStateProperty
which is used in APIs that need to accept either a Color or aWidgetStateProperty<Color>
. - WidgetStateMouseCursor, a MouseCursor that implements
WidgetStateProperty
which is used in APIs that need to accept either a MouseCursor or a WidgetStateProperty<MouseCursor>. - WidgetStateOutlinedBorder, an OutlinedBorder that implements
WidgetStateProperty
which is used in APIs that need to accept either an OutlinedBorder or a WidgetStateProperty<OutlinedBorder>. - WidgetStateBorderSide, a BorderSide that implements
WidgetStateProperty
which is used in APIs that need to accept either a BorderSide or a WidgetStateProperty<BorderSide>. - WidgetStateTextStyle, a TextStyle that implements
WidgetStateProperty
which is used in APIs that need to accept either a TextStyle or a WidgetStateProperty<TextStyle>.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
Set< WidgetState> states) → T -
Returns a value of type
T
that depends onstates
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
all<
T> (T value) → WidgetStateProperty< T> - Convenience method for creating a WidgetStateProperty that resolves to a single value for all states.
-
lerp<
T> (WidgetStateProperty< T> ? a, WidgetStateProperty<T> ? b, double t, T? lerpFunction(T?, T?, double)) → WidgetStateProperty<T?> ? - Linearly interpolate between two WidgetStatePropertys.
-
resolveAs<
T> (T value, Set< WidgetState> states) → T -
Resolves the value for the given set of states if
value
is a WidgetStateProperty, otherwise returns the value itself. -
resolveWith<
T> (WidgetPropertyResolver< T> callback) → WidgetStateProperty<T> - Convenience method for creating a WidgetStateProperty from a WidgetPropertyResolver function alone.