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.
link

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

See also:

Inheritance

Constructors

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

Properties

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.
final
onUndo ChangeNotifier
Notifies listeners that undo has been called.
final
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

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
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).
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
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.
inherited
toString() String
A string representation of this object.
inherited
undo() → void
Reverts the value on the stack to the previous value.

Operators

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