undo method

  1. @override
void undo()
override

Reverts the value on the stack to the previous value.

Implementation

@override
void undo() {
  if (_stack.currentValue == null)  {
    // Returns early if there is not a first value registered in the history.
    // This is important because, if an undo is received while the initial
    // value is being pushed (a.k.a when the field gets the focus but the
    // throttling delay is pending), the initial push should not be canceled.
    return;
  }
  if (_throttleTimer?.isActive ?? false) {
    _throttleTimer?.cancel(); // Cancel ongoing push, if any.
    _update(_stack.currentValue);
  } else {
    _update(_stack.undo());
  }
  _updateState();
}