StateManager class
Manages state for CLI interactions and provides access to stored values.
The StateManager class maintains a collection of CLIState objects and provides methods for adding, retrieving, and manipulating states. It also includes a stream for reactive updates when states change.
This class is essential for:
- Storing user inputs from various CLI prompts
- Retrieving values by index or label
- Subscribing to state changes through the stream API
Constructors
-
StateManager(List<
CLIState> initialStates) - Creates a StateManager with an initial list of states.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
states
→ List<
CLIState> -
Returns an unmodifiable view of all managed states.
no setter
- stateValues → List
-
Returns a list of all state values, extracting the appropriate values
based on the type of state.
no setter
-
stream
→ Stream<
List< CLIState> > -
A broadcast stream of state changes that can be subscribed to.
no setter
Methods
-
addMember(
CLIState newState) → void - Adds a new state to the collection and broadcasts the update.
-
dispose(
) → void - Dispose resources when no longer needed
-
getStateValueByIndex(
int index) → dynamic - Retrieves a state value by its index in the collection.
-
getStateValueByLabel(
String? label) → dynamic - Retrieves a state value by its label.
-
newList(
List< CLIState> newStates) → void - Replaces the entire state collection with a new list and broadcasts the update.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited