Check if context is still mounted before showing a popup [skip ci]

OmarHatem committed Feb 27, 2023 at 15:59 UTC 2c43f29d64adc344e463a4b1b32da721780e2d1a
3 files changed +9 -4
lib/src/screens/dashboard/dashboard_page.dart
+3 -2
@@ -8,7 +8,6 @@ import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
8 import 'package:cake_wallet/themes/theme_base.dart';
9 import 'package:cake_wallet/utils/show_pop_up.dart';
10 import 'package:flutter/material.dart';
11 -import 'package:flutter/cupertino.dart';
11 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
12 import 'package:cake_wallet/src/screens/base_page.dart';
13 import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.dart';
@@ -229,7 +228,8 @@ class DashboardPage extends BasePage {
228 }
229
230 await Future<void>.delayed(Duration(seconds: 1));
232 - await showPopUp<void>(
231 + if (context.mounted) {
232 + await showPopUp<void>(
233 context: context,
234 builder: (BuildContext context) {
235 return AlertWithOneAction(
@@ -239,6 +239,7 @@ class DashboardPage extends BasePage {
239 buttonText: S.of(context).understand,
240 buttonAction: () => Navigator.of(context).pop());
241 });
242 + }
243 });
244
245 var needToPresentYat = false;
lib/src/screens/dashboard/widgets/address_page.dart
+3 -1
@@ -117,7 +117,8 @@ class AddressPage extends BasePage {
117 }
118
119 await Future<void>.delayed(Duration(seconds: 1));
120 - await showPopUp<void>(
120 + if (context.mounted) {
121 + await showPopUp<void>(
122 context: context,
123 builder: (BuildContext context) {
124 return AlertWithTwoActions(
@@ -131,6 +132,7 @@ class AddressPage extends BasePage {
132 Navigator.of(context).pop();
133 });
134 });
135 + }
136 });
137
138 return KeyboardActions(
lib/src/screens/send/send_page.dart
+3 -1
@@ -379,7 +379,8 @@ class SendPage extends BasePage {
379
380 if (state is ExecutedSuccessfullyState) {
381 WidgetsBinding.instance.addPostFrameCallback((_) {
382 - showPopUp<void>(
382 + if (context.mounted) {
383 + showPopUp<void>(
384 context: context,
385 builder: (BuildContext context) {
386 return ConfirmSendingAlert(
@@ -423,6 +424,7 @@ class SendPage extends BasePage {
424 },
425 actionLeftButton: () => Navigator.of(context).pop());
426 });
427 + }
428 });
429 }
430