undo method
Implementation
bool undo({
required State Function() captureState,
required void Function(State state) restoreState,
}) {
if (_undoStack.isEmpty) {
return false;
}
breakCoalescing();
final current = captureState();
final previous = _undoStack.removeLast();
_redoStack.add(current);
restoreState(previous);
return true;
}