VisibilityInfo.fromRects constructor
Constructs a VisibilityInfo from widget bounds and a corresponding clipping rectangle.
widgetBounds and clipRect are expected to be in the same coordinate
system.
This factory is typically used internally by the visibility detection system to compute visibility based on the widget's position and any clipping applied by ancestor widgets.
Implementation
factory VisibilityInfo.fromRects({
required Key key,
required Rect widgetBounds,
required Rect clipRect,
}) {
// Compute the intersection in the widget's local coordinates.
final visibleBounds = widgetBounds.overlaps(clipRect)
? widgetBounds.intersect(clipRect).shift(-widgetBounds.topLeft)
: Rect.zero;
return VisibilityInfo(
key: key,
size: widgetBounds.size,
visibleBounds: visibleBounds,
);
}