getWidgetBounds method
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;
}