widgetBoundsFor method

Rect? widgetBoundsFor(
  1. Key key
)

Returns the last known bounds for the VisibilityDetector with the given key in global coordinates.

Returns null if the specified VisibilityDetector is not visible or is not found.

Example:

final bounds = VisibilityDetectorController.instance
    .widgetBoundsFor(Key('my-widget'));
if (bounds != null) {
  print('Widget is at: ${bounds.topLeft}');
}

Implementation

Rect? widgetBoundsFor(Key key) => VisibilityDetectorLayer.widgetBounds[key];