moveChildrenBy method
Move unique children together, validating every resulting position first.
Implementation
void moveChildrenBy(Iterable<CanvasChildId> ids, Offset gridDelta) {
_validateGeometry(position: gridDelta);
final positions = <CanvasChildId, Offset>{};
final bounds = <CanvasChildId, Rect>{};
for (final id in ids.toSet()) {
final child = _requireChild(id);
final position = child.gsPosition + gridDelta;
_validateGeometry(position: position);
positions[id] = position;
if (position != child.gsPosition) {
bounds[id] = _childBounds(
position,
child.lastRenderedSize,
child.rotation,
);
}
}
var changed = false;
for (final entry in positions.entries) {
changed =
_updateChild(
_children[entry.key]!,
entry.key,
position: entry.value,
bounds: bounds[entry.key],
) ||
changed;
}
if (changed) markDirty();
}