Check if widget is mounted before showing popups

This commit is contained in:
OmarHatem
2023-02-07 18:03:31 +02:00
parent a8025ffbec
commit bf407bedec
3 changed files with 22 additions and 20 deletions
+9 -11
View File
@@ -365,17 +365,15 @@ class SendPage extends BasePage {
reaction((_) => sendViewModel.state, (ExecutionState state) {
if (state is FailureState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (context.mounted) {
showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).error,
alertContent: state.error,
buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop());
});
}
showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).error,
alertContent: state.error,
buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop());
});
});
}