0

I'm trying to make a popup menu for my appbar, but when the menu is open, I cannot press a button on the scaffold before dismissing it first. This is similarly true for dialog widgets.

How can I override this behavior? I wish for widgets like popupmenu and dialog to behave the same, and be dismissable in a similar way, except not block any other interactions when clicking outside barrier.

weg
  • 11
  • 2

3 Answers3

0

Just invoke the method showDialog() that have a bool barrierDismissible. Pass it to true.

Example :

showDialog(
    barrierDismissible: true,
    context: context,
    builder: (BuildContext context) {
        return AlertDialog(
            title: const Text("Dismiss Barrier"),
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(30),
            ),
            ...
        );
    }
);
RBE
  • 87
  • 3
  • this bool is true by default, not relevant to my question. the situation is I want to click buttons where the dark background usually is without double clicking (1. dismiss 2. onpressed) – weg Jun 06 '22 at 18:23
0
  1. Try to use OverlayEntry
  2. Follow this tutorial to understand the different between ShowDialog and OverlayEntry
Drogbut
  • 37
  • 4
0

I would recommend anyone who runs into this problem to use flutter_smart_dialog.
Call SmartDialog.show(...) and specify usePenetrate: true.
Otherwise follow Drogbut's answer

weg
  • 11
  • 2