undo method

void undo()

Revert the previous operation if there is one.

Implementation

void undo() {
  if (history.isNotEmpty) {
    index = history.removeLast();
  }
}