UndoHistoryController class

A controller for the undo history, for example for an editable text field.

Whenever a change happens to the underlying value that the UndoHistory widget tracks, that widget updates the value and the controller notifies it's listeners. Listeners can then read the canUndo and canRedo properties of the value to discover whether undo or redo are possible.

The controller also has undo and redo methods to modify the undo history.

This example creates a TextField with an UndoHistoryController which provides undo and redo buttons.

To create a local project with this code sample, run:
flutter create --sample=widgets.UndoHistoryController.1 mysample

See also:



UndoHistoryController({UndoHistoryValue? value})
Creates a controller for an UndoHistory widget.


hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
onRedo ChangeNotifier
Notifies listeners that redo has been called.
onUndo ChangeNotifier
Notifies listeners that undo has been called.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value UndoHistoryValue
The current value stored in this notifier.
getter/setter pairinherited


addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
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).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
notifyListeners() → void
Call all the registered listeners.
redo() → void
Updates the value on the stack to the next value.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
toString() String
A string representation of this object.
undo() → void
Reverts the value on the stack to the previous value.


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