undo method

T? undo(
  1. T currentState
)

Undoes the last command.

Implementation

T? undo(T currentState) {
  if (!canUndo) return null;

  final command = _undoStack.last;
  final previous = command.undo(currentState);
  _undoStack.removeLast();
  _redoStack.add(command);
  return previous;
}