flutter-alertify
flutter-alertify copied to clipboard
Alertify not properly dismissing, popping back to the previous fullscreen page.
Hello, I"m currently having some trouble with implementing Alertify into our code. The following code is the request to our API to validate a user's document (details are obfuscated due to proprietary code).
void postRequestFunction() async {
if (...) {
showAlertDialog(context);
...URL cleanup code
...Document cleanup code
try {
// Send request code
if (res.statusCode == 200) {
Navigator.of(context, rootNavigator: true).pop();
print(resBody);
Navigator.push(context,
MaterialPageRoute(builder: (context) => ValidarTokenSMS()));
} else {
Navigator.of(context, rootNavigator: false).pop();
Alertify(
content: body,
context: context,
isDismissible: true,
title: title,
alertType: AlertifyType.warning,
buttonText: 'Ok',
animationType: AnimationType.outToIn).show();
}
} catch (error) {
await utils.reportError(error);
}
} else {
Alertify(
content: body,
context: context,
isDismissible: true,
title: title,
alertType: AlertifyType.warning,
buttonText: 'Ok',
animationType: AnimationType.outToIn)
.show();
}
}
The problem that is happening is:
I'm entering the signup page. Then the user types in the stuff, it sends the request and we open a popup to say it's loading. It returns an error (intentional). The Alertify popup appears. I click the ok to dismiss, it pops me back to the login page, but doesn't pop the Alertify popup - continuing to click the ok throws FlutterErrors (for trying to pop a guy that is no longer in the widget tree). It does let me click outside the popup to dismiss it, though.