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.
CodePudding user response:
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()
CodePudding user response:
Here you got a simple example of how I hide the Dialog and do a function after.
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("test title"),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text("test data"),
],
),
),
actions: <Widget>[
MaterialButton(
child: Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
doFunction();
},
),
],
);
});