Undoable mixin
A mixin on OrbitStore that opts the store into global undo/redo support.
Stores mixing in Undoable must implement restore to restore state fields from a previously captured state map (returned by snapshot).
- Superclass constraints
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- initError ↔ Object?
-
Set if init threw synchronously, or its returned future
completed with an error.
nullotherwise.getter/setter pairinherited - initStackTrace ↔ StackTrace?
-
The stack trace paired with initError, if any.
getter/setter pairinherited
- isReady → bool
-
True once ready has completed successfully.
falseif it hasn't completed yet, or if it completed with an error — check initError to tell those two apart.no setterinherited -
ready
→ Future<
void> -
Completes once init finishes.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
batch<
T> (FutureOr< T> fn(), {String? label}) → FutureOr<T> -
Runs
fninside a store-scoped batch.inherited -
debounce(
String id, Duration duration, FutureOr< void> action()) → void -
Debounces
action, executing it only afterdurationof inactivity.inherited -
dispose(
) → void -
Discards any resources used by the object.
inherited
-
inferLabelForTest(
String? explicitLabel, StackTrace trace) → String? -
Exposed helper for testing label inference on custom stack traces.
inherited
-
init(
) → FutureOr< void> -
Called exactly once, immediately after the store is first created
by
Orbit.use(orOrbitScope). Override to run setup logic — e.g. loading persisted state from disk, or an initial network fetch. Can be synchronous or asynchronous.inherited -
mutate<
R> (R action(), {String? label}) → R -
Runs
action, then notifies every listener that state changed.override -
mutateAsync<
T> ({required Future< T> action(), required void apply(T result), void onError(Object error, StackTrace stack)?, String? label}) → Future<void> -
Asynchronously executes
action, then passes the result toapplyinside mutate if successful.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
onDispose(
) → void -
Called when this store is disposed — via
Orbit.reset<T>(),Orbit.resetAll(),Orbit.override<T>(), or when anOrbitScope<T>unmounts. Override to clean up timers, stream subscriptions, and the like. Runs before the underlyingChangeNotifieris disposed.inherited -
onResume(
) → void -
Called when the app returns to the foreground
(
AppLifecycleState.resumed) while this store is alive — handy for refreshing time-sensitive data. No-op by default.inherited -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
restore(
Map< String, Object?> state) → void - Applies a previously captured snapshot (from OrbitStore.snapshot) back onto this store's fields. Called by Orbit.undo()/redo() — never call this directly.
-
snapshot(
) → Map< String, Object?> ? -
Override to return a snapshot of your state's fields.
inherited
-
throttle(
String id, Duration duration, FutureOr< void> action()) → void -
Throttles
action, executing it immediately and rate-limiting subsequent calls to at most once perduration.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
watch<
S extends OrbitStore> (OrbitStoreRef< S> storeRef, void onChange(S store)) → void -
Watches another global store and executes
onChangewhenever it notifies. Automatically unsubscribes when this store is disposed.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited