moveChildrenBy method

void moveChildrenBy(
  1. Iterable<CanvasChildId> ids,
  2. Offset gridDelta
)

Move unique children together, validating every resulting position first.

Implementation

void moveChildrenBy(Iterable<CanvasChildId> ids, Offset gridDelta) {
  _validateGeometry(position: gridDelta);
  final positions = <CanvasChildId, Offset>{};
  for (final id in ids.toSet()) {
    final position = _requireChild(id).gsPosition + gridDelta;
    _validateGeometry(position: position);
    positions[id] = position;
  }
  var changed = false;
  for (final entry in positions.entries) {
    changed =
        _updateChild(
          _children[entry.key]!,
          entry.key,
          position: entry.value,
        ) ||
        changed;
  }
  if (changed) markDirty();
}