updateShape method

void updateShape(
  1. UDocShape shape
)

Rapid edits of one shape (dragging, resizing) share one undo step.

Implementation

void updateShape(UDocShape shape) {
  final int index = _shapes.indexWhere((UDocShape existing) => existing.id == shape.id);
  if (index < 0) return;
  final DateTime now = DateTime.now();
  if (_lastShapeEdit != shape.id || now.difference(_lastShapeEditAt) >= const Duration(milliseconds: 900)) _checkpoint();
  _lastShapeEdit = shape.id;
  _lastShapeEditAt = now;
  _shapes[index] = shape;
  _commit(debounce: true);
}