Search code examples
flutterdartpopupnavigatorflutter-alertdialog

Flutter - how to make popup disapears when there a multiple popups?


My problem is pretty straightforward.

I click on a button, then popup1 shows up, then I click on a button on popup1 and popup2 shows up, I click on a button popup2 and popup2 disapears, BUT popup1 is still there.

How do I make popup1 also disapear when clicking on a button on popup2 ?

NB: I am referencing the AlertDialog widget when talking about popups.

Thanks.


Solution

  • When you click on button from Popup 1 to Open Popup 2, you need to call pop method to pop Popup 1 after opening popup 2.Add below code to pop Popup 1.

    Navigator.of(context, rootNavigator: true).pop()