Ensure widget is still mounted before showing popup

This commit is contained in:
OmarHatem 2023-02-06 19:08:44 +02:00
parent c94aed6fb1
commit 03f5544545

View file

@ -365,6 +365,7 @@ class SendPage extends BasePage {
reaction((_) => sendViewModel.state, (ExecutionState state) { reaction((_) => sendViewModel.state, (ExecutionState state) {
if (state is FailureState) { if (state is FailureState) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (context.mounted) {
showPopUp<void>( showPopUp<void>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -374,6 +375,7 @@ class SendPage extends BasePage {
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop()); buttonAction: () => Navigator.of(context).pop());
}); });
}
}); });
} }