isPositionVisibleGlobally static method
Returns true
if the entire content rectangle at position
is visible on
screen, or false
otherwise.
By default, this method expects a single SuperReader in the widget tree and
finds it byType
. To specify one SuperReader among many, pass a superDocumentFinder
.
Implementation
static bool isPositionVisibleGlobally(DocumentPosition position, Size globalSize, [Finder? finder]) {
final documentLayout = _findDocumentLayout(finder);
final positionRect = documentLayout.getRectForPosition(position)!;
final globalDocumentOffset = documentLayout.getGlobalOffsetFromDocumentOffset(Offset.zero);
final globalPositionRect = positionRect.translate(globalDocumentOffset.dx, globalDocumentOffset.dy);
return globalPositionRect.top >= 0 &&
globalPositionRect.left >= 0 &&
globalPositionRect.bottom <= globalSize.height &&
globalPositionRect.right <= globalSize.width;
}