1

i am trying to make a custom showMenu and want to dismiss the showmenu when mouse exit the PopupMenuItem. any suggesion? here is what i did so far

   void _showPopupMenu() async {
        await showMenu(
          constraints: BoxConstraints(minWidth: 800),
          color: Colors.black.withOpacity(0.5),
          context: context,
          position: RelativeRect.fromLTRB(150, 50, 150, 100),
          items: [
            PopupMenuItem(
                enabled: false,
                onTap: null,
                child: MouseRegion(
                  onExit: (e) {
                    //Should hide the showMenu
                  },
                  child: Container(
                    width: 800,
                    height: 400,
                    child: Column(
                      children: [
                        Row(
                          children: [Text('Hello')],
                        )
                      ],
                    ),
                  ),
                ))
          ],
          elevation: 8.0,
        ).then((value) {
      
          if (value != null) print(value);
        });
      }
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30

1 Answers1

1

You can use Navigator.pop

onExit: (e) {
                   Navigator.pop(context);
     },
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30