getWidgetBounds static method

Rect getWidgetBounds(
  1. BuildContext context
)

get Widget Bounds (width, height, left, top, right, bottom and so on).Widgets must be rendered completely. 获取widget Rect

Implementation

static Rect getWidgetBounds(BuildContext context) {
  RenderObject? box = context.findRenderObject();
  return (box != null) ? box.semanticBounds : Rect.zero;
}