getWidgetLocalToGlobal method

Offset getWidgetLocalToGlobal(
  1. BuildContext context
)

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

Implementation

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