getWidgetBounds 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

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