Command<T extends Object> class sealed

Represents a generic command with lifecycle and execution.

This class supports state management, notifications, and execution with optional cancellation and history tracking.

Inheritance
Implemented types
Mixed-in types
Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isCancelled bool
isCancelled: Checks if the command has been cancelled.
no setter
isFailure bool
isFailure: Checks if the command execution failed.
no setter
isIdle bool
isIdle: Checks if the command is in the idle state.
no setter
isRunning bool
isRunning: Checks if the command is currently running.
no setter
isSuccess bool
isSuccess: Checks if the command execution was successful.
no setter
maxHistoryLength int
The maximum length of the state history.
getter/setter pairinherited
onCancel → void Function()?
Callback executed when the command is cancelled.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stateHistory List<CommandHistoryEntry<T>>
Provides read-only access to the state change history.
no setterinherited
value CommandState<T>
The current value of the object. When the value changes, the callbacks registered with addListener will be invoked.
no setteroverride

Methods

addHistoryEntry(CommandHistoryEntry<T> entry) → void
Adds a new entry to the history and ensures the history length limit.
inherited
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
cancel({Map<String, dynamic>? metadata}) → void
Cancels the execution of the command.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
filter<W>(W defaultValue, W? func(CommandState<T>)) ValueListenable<W>
Filters the current command state and returns a ValueListenable with the transformed value.
getCachedFailure() Exception?
Returns the cached exception of the FailureCommand, or null if not found.
getCachedSuccess() → T?
Returns the cached value of the SuccessCommand, or null if not found.
initializeHistoryManager(int maxHistoryLength) → void
Initializes the history manager with a maximum length.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
reset({Map<String, dynamic>? metadata}) → void
Resets the command state to IdleCommand.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

setObserverListener(void listener(CommandState<Object> state)) → void
Sets the default observer listener for all commands. This listener is called whenever the state of any command changes. This can be useful for logging, debugging, or global state management.