UndoableNotifier<T> class

A reactive notifier with undo/redo history support.

UndoableNotifier maintains a history stack and a future stack to enable time-travel state management.

Example:

final counter = UndoableNotifier<int>(0, maxHistory: 10);

counter.value = 1;
counter.value = 2;
counter.value = 3;

counter.undo(); // value = 2
counter.undo(); // value = 1
counter.redo(); // value = 2
Inheritance
Available extensions

Constructors

UndoableNotifier(T initialValue, {int maxHistory = 10})
Creates an UndoableNotifier with the given initial value and max history.

Properties

canRedo → bool
Whether redo is available.
no setter
canUndo → bool
Whether undo is available.
no setter
futureLength → int
Returns the number of entries in the future stack.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
historyLength → int
Returns the number of entries in the history stack.
no setter
maxHistory → int
Maximum number of history entries to keep.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value ↔ T
The current value of this notifier.
getter/setter pairinherited-getteroverride-setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
asStream() → Stream<T>

Available on ReactiveNotifier<T>, provided by the StreamExtensions extension

Converts this notifier to a broadcast stream.
clearHistory() → void
Clears all history and future stacks.
dispose() → void
Clears history and future stacks, then disposes the notifier.
override
distinct([bool equals(T previous, T current)?]) → ReactiveNotifier<T>

Available on ReactiveNotifier<T>, provided by the FilteredExtensions extension

Returns a derived notifier that only updates when the value changes.
forceUpdate(T newValue) → void
Updates the value without checking for equality.
inherited
listen(void callback(T newValue)) → VoidCallback
Subscribes to value changes and returns a dispose function.
inherited
map<R>(R mapper(T value)) → ReactiveNotifier<R>

Available on ReactiveNotifier<T>, provided by the FilteredExtensions extension

Returns a derived notifier with transformed values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() → void
Reapplies the next value from the future stack.
refresh() → void
Forces a notification to all listeners without changing the value.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
reset() → void
Resets the value to its initial state.
inherited
silentSet(T newValue) → void
Sets the value without notifying listeners.
inherited
silentUpdate(T updater(T current)) → void
Updates the value using a function without notifying listeners.
inherited
toString() → String
A string representation of this object.
inherited
undo() → void
Reverts to the previous value in history.
update(T updater(T current)) → void
Updates the value using a function.
inherited
where(bool predicate(T value)) → ReactiveNotifier<T>

Available on ReactiveNotifier<T>, provided by the FilteredExtensions extension

Returns a derived notifier that only updates when the predicate is true.

Operators

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