From 03f55445457251e366c5c5501e5b198aa5ccf99f Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Mon, 6 Feb 2023 19:08:44 +0200 Subject: [PATCH] Ensure widget is still mounted before showing popup --- lib/src/screens/send/send_page.dart | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 2cd849f34..6f4cd0bde 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -339,7 +339,7 @@ class SendPage extends BasePage { showErrorValidationAlert(context); return; } - + await sendViewModel.createTransaction(); }, @@ -365,15 +365,17 @@ class SendPage extends BasePage { reaction((_) => sendViewModel.state, (ExecutionState state) { if (state is FailureState) { WidgetsBinding.instance.addPostFrameCallback((_) { - showPopUp( - 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()); - }); + if (context.mounted) { + showPopUp( + 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()); + }); + } }); }