Check if widget is mounted before showing popups

wow-support
OmarHatem 1 year ago
parent a8025ffbec
commit bf407bedec

@ -365,7 +365,6 @@ 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) {
@ -375,7 +374,6 @@ class SendPage extends BasePage {
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop()); buttonAction: () => Navigator.of(context).pop());
}); });
}
}); });
} }

@ -120,6 +120,7 @@ class ExceptionHandler {
static bool _ignoreError(String error) { static bool _ignoreError(String error) {
return error.contains("errno = 103") || // SocketException: Software caused connection abort return error.contains("errno = 103") || // SocketException: Software caused connection abort
error.contains("errno = 9") || // SocketException: Bad file descriptor error.contains("errno = 9") || // SocketException: Bad file descriptor
error.contains("errno = 32") || // SocketException: Write failed (OS Error: Broken pipe)
error.contains("errno = 54"); // SocketException: Connection reset by peer error.contains("errno = 54"); // SocketException: Connection reset by peer
} }
} }

@ -8,7 +8,8 @@ Future<T?> showPopUp<T>({
bool useSafeArea = false, bool useSafeArea = false,
bool useRootNavigator = true, bool useRootNavigator = true,
RouteSettings? routeSettings RouteSettings? routeSettings
}) { }) async {
if (context.mounted) {
return showDialog<T>( return showDialog<T>(
context: context, context: context,
builder: builder, builder: builder,
@ -17,4 +18,6 @@ Future<T?> showPopUp<T>({
useSafeArea: useSafeArea, useSafeArea: useSafeArea,
useRootNavigator: useRootNavigator, useRootNavigator: useRootNavigator,
routeSettings: routeSettings); routeSettings: routeSettings);
}
return null;
} }

Loading…
Cancel
Save