From 597b97414d34b189e7d34ebf39fdf9c81ba6f506 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Tue, 31 Mar 2026 06:04:30 +0530 Subject: [PATCH] fix: suppress all network errors during logout and clear snackbars before navigation --- lib/core/network/api_client.dart | 11 ++++++----- .../home/presentation/widgets/home_header.dart | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/core/network/api_client.dart b/lib/core/network/api_client.dart index 9c56e05..1916d2e 100644 --- a/lib/core/network/api_client.dart +++ b/lib/core/network/api_client.dart @@ -62,12 +62,13 @@ class ApiClient { return InterceptorsWrapper( onError: (error, handler) async { // Handle 401 — attempt token refresh + // During logout, silently swallow ALL errors + if (suppressAuthErrors) { + handler.reject(error); + return; + } + if (error.response?.statusCode == 401) { - // During logout, silently reject 401s without showing errors - if (suppressAuthErrors) { - handler.reject(error); - return; - } final requestUrl = error.requestOptions.path; diff --git a/lib/features/home/presentation/widgets/home_header.dart b/lib/features/home/presentation/widgets/home_header.dart index 3c9dee2..607488d 100644 --- a/lib/features/home/presentation/widgets/home_header.dart +++ b/lib/features/home/presentation/widgets/home_header.dart @@ -323,6 +323,7 @@ class _MenuDrawer extends ConsumerWidget { child: ElevatedButton( onPressed: () { Navigator.pop(context); + ScaffoldMessenger.of(context).clearSnackBars(); ref.read(authProvider.notifier).logout(); }, style: ElevatedButton.styleFrom(