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.
Implementation
factory VisibilityInfo.fromRects({
required Key key,
required Rect widgetBounds,
required Rect clipRect,
}) {
final bool overlaps = widgetBounds.overlaps(clipRect);
// Compute the intersection in the widget's local coordinates.
final visibleBounds = overlaps
? widgetBounds.intersect(clipRect).shift(-widgetBounds.topLeft)
: Rect.zero;
return VisibilityInfo(
key: key,
size: widgetBounds.size,
visibleBounds: visibleBounds,
);
}