UndoHistory<T> class

Provides undo/redo capabilities for a ValueNotifier.

Listens to value and saves relevant values for undoing/redoing. The cadence at which values are saved is a best approximation of the native behaviors of a number of hardware keyboard on Flutter's desktop platforms, as there are subtle differences between each of the platforms.

Listens to keyboard undo/redo shortcuts and calls onTriggered when a shortcut is triggered that would affect the state of the value.

The child must manage focus on the focusNode. For example, using a TextField or Focus widget.

Inheritance

Constructors

UndoHistory({Key? key, bool shouldChangeUndoStack(T? oldValue, T newValue)?, required ValueNotifier<T> value, required void onTriggered(T value), required FocusNode focusNode, T undoStackModifier(T value)?, UndoHistoryController? controller, required Widget child})
Creates an instance of UndoHistory.
const

Properties

child → Widget
The child widget of UndoHistory.
final
controller → UndoHistoryController?
Controls the undo state.
final
focusNode → FocusNode
The FocusNode that will be used to listen for focus to set the initial undo state for the element.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onTriggered → void Function(T value)
Called when an undo or redo causes a state change.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shouldChangeUndoStack → bool Function(T? oldValue, T newValue)?
Called when checking whether a value change should be pushed onto the undo stack.
final
undoStackModifier → T Function(T value)?
Called right before a new entry is pushed to the undo stack.
final
value → ValueNotifier<T>
The value to track over time.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<UndoHistory<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

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