findGlobalRect static method

Rect? findGlobalRect(
  1. GlobalKey<State<StatefulWidget>> key
)

Implementation

static Rect? findGlobalRect(GlobalKey key) {
  RenderBox renderObject =
      key.currentContext?.findRenderObject() as RenderBox;

  var globalOffset = renderObject.localToGlobal(Offset.zero);

  var bounds = renderObject.paintBounds;
  bounds = bounds.translate(globalOffset.dx, globalOffset.dy);
  return bounds;
}