StatedWidget constructor
const
StatedWidget({})
Creates a StatedWidget with explicit state-specific widgets.
Provides dedicated widget instances for each supported state.
The child serves as the default widget when no specific state
matches or when no state-specific widget is provided.
State resolution follows the order priority, with earlier states
taking precedence. The first matching state with a non-null widget
is selected for display.
Parameters:
child(Widget, required): Default widget for normal stateorder(Listdisabled(Widget?, optional): Widget for disabled stateselected(Widget?, optional): Widget for selected statepressed(Widget?, optional): Widget for pressed/active statehovered(Widget?, optional): Widget for hover statefocused(Widget?, optional): Widget for focused stateerror(Widget?, optional): Widget for error state
Example:
StatedWidget(
child: Icon(Icons.star_border),
selected: Icon(Icons.star, color: Colors.yellow),
hovered: Icon(Icons.star_border, color: Colors.grey),
disabled: Icon(Icons.star_border, color: Colors.grey.shade300),
)
Implementation
const factory StatedWidget({
Key? key,
required Widget child,
List<WidgetState> order,
Widget? disabled,
Widget? selected,
Widget? pressed,
Widget? hovered,
Widget? focused,
Widget? error,
}) = _ParamStatedWidget;