getWidgetPosition function

Offset getWidgetPosition({
  1. GlobalKey<State<StatefulWidget>>? key,
  2. BuildContext? context,
  3. RenderObject? parent,
})

Implementation

Offset getWidgetPosition({
  GlobalKey? key,
  BuildContext? context,
  RenderObject? parent,
}) {
  BuildContext ctx = context ?? key!.currentContext!;
  final renderBox = ctx.findRenderObject() as RenderBox;
  return renderBox.localToGlobal(Offset.zero, ancestor: parent);
}