ReactiveStatus<T> class
A widget that conditionally renders content based on the current reactive status of type T
.
It listens to global status changes triggered by refreshStatus, and builds the corresponding widget defined in cases. If the current status is not handled, it falls back to defaultCase or renders an empty widget.
Useful for managing reactive UI flow based on enum-like states.
Example:
enum MyStatus { loading, success, error }
ReactiveStatus<MyStatus>(
cases: {
MyStatus.loading: () => CircularProgressIndicator(),
MyStatus.success: () => Text("Done!"),
MyStatus.error: () => Text("Oops!"),
},
defaultCase: () => Text("Idle"),
)
// Somewhere else:
refreshStatus(MyStatus.loading);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ReactiveStatus
Constructors
-
ReactiveStatus.new(Map<
T, Widget Function()> cases, {Key? key, Widget defaultCase()?, Key? reactiveKey}) -
Creates a ReactiveStatus widget that reacts to changes in the global status of type
T
.
Properties
-
cases
→ Map<
T, Widget Function()> -
A map of status values to widget builder functions.
final
- defaultCase → Widget Function()?
-
A fallback builder used when no case matches the current status.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- reactiveKey → Key
-
The key used to subscribe this widget to status updates.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ReactiveStatus< T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited