showPopMenu<T> static method

Future<T?> showPopMenu<T>(
  1. BuildContext context, {
  2. required List<PopupMenuEntry<T>> items,
  3. double offsetX = 0,
  4. dynamic offsetY = 0,
})

Implementation

static Future<T?> showPopMenu<T>(BuildContext context,
    {required List<PopupMenuEntry<T>> items,
    double offsetX = 0,
    offsetY = 0}) {
  var x = MediaQuery.of(context).size.width / 2 + offsetX;
  final RenderBox renderBox = context.findRenderObject() as RenderBox;
  Offset offset = renderBox.localToGlobal(Offset.zero);
  var y = offset.dy + renderBox.size.height + offsetY;
  //计算弹框展示位置
  final RelativeRect position = RelativeRect.fromLTRB(x, y, x, 0);
  return showMenu(context: context, position: position, items: items);
}