showPopup method

void showPopup({
  1. required BuildContext context,
  2. AlignmentGeometry alignment = Alignment.topLeft,
  3. Offset? relativePosition,
  4. double? left,
  5. double? top,
  6. double? right,
  7. double? bottom,
})

Implementation

void showPopup({
  required BuildContext context,
  AlignmentGeometry alignment = Alignment.topLeft,
  Offset? relativePosition,
  double? left,
  double? top,
  double? right,
  double? bottom,
}) {
  assert(this._myPopup != null);
  if (this._myPopup == null || this._overlayEntry != null) {
    return;
  }
  var l = left, t = top, r = right, b = bottom;
  if (relativePosition != null) {
    final renderBox = this._myPopup!._globalKey.currentContext?.findRenderObject() as RenderBox;
    final offset = renderBox.localToGlobal(relativePosition);
    l = (l ?? 0.0) + offset.dx;
    t = (t ?? 0.0) + offset.dy;
  }
  this._overlayEntry = OverlayEntry(
    builder: (context) {
      return WBlurryOverlay(
        child: GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () {
            this.hidePopup();
          },
          child: Padding(
            padding: EdgeInsets.only(
              top: t ?? 0.0,
              left: l ?? 0.0,
              right: r ?? 0.0,
              bottom: b ?? 0.0,
            ),
            child: Align(
              alignment: alignment,
              child: this._myPopup!.popupBuilder(context, this.hidePopup),
            ),
          ),
        ),
      );
    },
  );

  Overlay.of(context).insert(_overlayEntry!);

  if (this.duration != null) {
    Future.delayed(this.duration!, () {
      this.hidePopup();
    });
  }
}