0

I am trying to Show popup Menu with showMenu

Here is the minimal code

onPressed: () {
    final RenderBox renderBox = _showMenuKey.currentContext?.findRenderObject() as RenderBox;
    final Size size = renderBox.size;
    final Offset offset = renderBox.localToGlobal(Offset.zero);

    showMenu(
        context: context,
        position: RelativeRect.fromLTRB(
        offset.dx,
        offset.dy + size.height,
        offset.dx + size.width,
        offset.dy + size.height,
    ),
    items: List.generate(
        categoryItems.length,
        (index) => PopupMenuItem(
            value: index,
            child: Text(categoryItems[index])),
        ),
    ).then(
        (value) {
            if (value != null) {
                debugPrint(value.toString());
            }
        },
    );
},

This is the output

When I try to show this PopupMenu with OpenedKeyboard, the item list goes behind the keyboard. like this image. Popup Item behind Keyboard.

Changing Bottom Value with offset.dy + size.height+250, didn't move the PopupMenu top of the Keyboard

position: RelativeRect.fromLTRB(
  offset.dx,                 //Left
  offset.dy + size.height,   //Top
  offset.dx + size.width,    //Right
  offset.dy + size.height,   //Bottom
),

** So, how i position the PopupMenu on top of Opened Keyboard? **

I want to show Menu item anchoring from Bottom like this Image show PopupMenu on Top of Open Keyboard.

I've also tried showPop using Gesture Detector but failed

abdullah_bd
  • 484
  • 3
  • 12

0 Answers0