show static method

dynamic show(
  1. BuildContext context, {
  2. required Widget child,
  3. GlobalKey<State<StatefulWidget>>? tapWidgetKey,
  4. double? dx,
})

Implementation

static show(
  BuildContext context, {
  required Widget child,
  GlobalKey? tapWidgetKey,
  double? dx,
}) {
  Offset? offset;
  if (tapWidgetKey != null) {
    final renderObject = tapWidgetKey.currentContext?.findRenderObject();
    if (renderObject != null && renderObject is RenderBox) {
      //获得控件正下方的坐标
      offset = renderObject.localToGlobal(Offset(dx ?? 0.0, renderObject.size.height));
    }
  }
  if (offset != null) {
    _entry = OverlayEntry(
        builder: (BuildContext context) => XFloatContent(
              child: child,
              offset: offset,
            ));
  }
  if (_entry != null) Overlay.of(context)?.insert(_entry!);
}