undo method

void undo()

Undoes the last action performed on drawables. The action can later be redone.

If canUndo is false, nothing happens and notifyListeners is not called.

Calling this will notify all the listeners of this PainterController that they need to update (it calls notifyListeners). For this reason, this method should only be called between frames, e.g. in response to user actions, not during the build, layout, or paint phases.

Implementation

void undo() {
  if (!canUndo) return;
  final action = performedActions.removeLast();
  action.unperform(this);
  unperformedActions.add(action);
}