While dismissing a presented Cupertino alert dialogue action using the explained method my entire screen gets popped of and the alert dialogue stays on the screen. This is my code.
if (deviceList.isEmpty){
var alert = new CupertinoAlertDialog(
title: new Text("Alert"),
content: new Text("There was an error signing in. Please try again."),
actions: <Widget>[
new CupertinoDialogAction(
child: const Text('Discard'),
isDestructiveAction: true,
onPressed: () { Navigator.pop(context, 'Discard'); }
),
new CupertinoDialogAction(
child: const Text('Cancel'),
isDefaultAction: true,
onPressed: () { Navigator.pop(context, 'Cancel'); }
),
],
);
showDialog(context: context, child: alert);
}
Is there anything wrong in what I am doing? I cant find any other solution to dismiss the alert dialogue. Please help.
If you don't want to return any result after showDialog is closed, you can use it. Navigator. pop(context);
To prevent the dialog from closing on outside barrier touch, you have to set barrierDismissible to false. It is true by default.
Background the app on the phone, e.g. by going back to the home screen. Press the Stop button in Xcode to terminate the app while running in the background. Open the app again on the phone (not via Xcode). It will restart and restore its state.
In this case, you need to specify the rootNavigator
to of()
:
Navigator.of(context, rootNavigator: true).pop("Discard");
Check the implementation proposed in the documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With