getWidgetLocalToGlobal static method

Offset getWidgetLocalToGlobal(
  1. BuildContext context
)

Get the coordinates of the widget on the screen.Widgets must be rendered completely. 获取widget在屏幕上的坐标,widget必须渲染完成

Implementation

static Offset getWidgetLocalToGlobal(BuildContext context) {
  RenderBox? box = context.findRenderObject() as RenderBox?;
  return box == null ? Offset.zero : box.localToGlobal(Offset.zero);
}