undoLastAnnotationStroke method

AnnotationStroke? undoLastAnnotationStroke(
  1. String sharerIdentity,
  2. String localIdentity
)

Removes and returns the last stroke drawn by localIdentity for undo.

Implementation

AnnotationStroke? undoLastAnnotationStroke(
    String sharerIdentity, String localIdentity) {
  final list = _strokesBySharer[sharerIdentity];
  if (list == null) return null;
  final idx = list.lastIndexWhere((s) => s.fromIdentity == localIdentity);
  if (idx == -1) return null;
  final stroke = list[idx];
  list.removeAt(idx);
  notifyListeners();
  return stroke;
}