overlappingChildren method

List<CanvasChildId> overlappingChildren(
  1. Rect canvasRect
)

Finds children intersecting canvasRect in canvas/grid coordinates. Returns an immutable back-to-front snapshot without building or notifying. Uses rotated layout rectangles, including cached sizes of culled children; unknown or empty sizes and edge-only contact do not count as overlap. Throws ArgumentError for nonfinite bounds; empty rectangles return no IDs.

Implementation

List<CanvasChildId> overlappingChildren(Rect canvasRect) {
  if (!canvasRect.isFinite) {
    throw ArgumentError.value(canvasRect, 'canvasRect', 'Must be finite');
  }
  if (canvasRect.isEmpty) return const [];
  final footprint = Path()..addRect(canvasRect);
  return List.unmodifiable(
    childOrder.where((id) {
      final size = _children[id]!.lastRenderedSize;
      return size != null &&
          !size.isEmpty &&
          _footprintsOverlap(footprint, _childFootprint(id));
    }),
  );
}