From 985e968c5e87bbd2e26da124a8bdf2b0d1541c1e Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 20 May 2026 11:25:11 +0700 Subject: [PATCH] Remove redundant null assertions where flow analysis proves non-null --- lib/features/caching/caching_manager.dart | 2 +- .../controller/single_email_controller.dart | 12 ++++++------ .../presentation/sentry_ecosystem.dart | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/features/caching/caching_manager.dart b/lib/features/caching/caching_manager.dart index e6a4f8367..e0888ed56 100644 --- a/lib/features/caching/caching_manager.dart +++ b/lib/features/caching/caching_manager.dart @@ -108,7 +108,7 @@ class CachingManager { _tokenOidcCacheManager.clear(), _authenticationInfoCacheManager.clear(), if (PlatformInfo.isMobile && _sentryConfigurationCacheManager != null) - _sentryConfigurationCacheManager!.clearSentryConfiguration(), + _sentryConfigurationCacheManager.clearSentryConfiguration(), ], eagerError: true); } catch (e) { logWarning('CachingManager::clearAccountDataCached: Cannot clear account data cache: $e'); diff --git a/lib/features/email/presentation/controller/single_email_controller.dart b/lib/features/email/presentation/controller/single_email_controller.dart index 22c299bf6..2426b74ec 100644 --- a/lib/features/email/presentation/controller/single_email_controller.dart +++ b/lib/features/email/presentation/controller/single_email_controller.dart @@ -316,7 +316,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin { for (var worker in obxListeners) { worker.dispose(); } - Get.delete(tag: _currentEmailId!.id.value); + Get.delete(tag: _currentEmailId.id.value); } else if (action is UnsubscribeFromThreadAction) { if (_currentEmailId == null || action.emailId != _currentEmailId) return; _handleUnsubscribe(action.listUnsubscribe); @@ -325,13 +325,13 @@ class SingleEmailController extends BaseController with AppLoaderMixin { for (var worker in obxListeners) { worker.dispose(); } - Get.delete(tag: _currentEmailId!.id.value); + Get.delete(tag: _currentEmailId.id.value); } else if (action is OpenAttachmentListAction) { if (_currentEmailId == null || action.emailId != _currentEmailId) { return; } jumpToAttachmentList( - emailId: _currentEmailId!, + emailId: _currentEmailId, countAttachments: action.countAttachments, screenHeight: action.screenHeight, isDisplayAllAttachments: action.isDisplayAllAttachments, @@ -486,8 +486,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin { } void _getEmailContentAction(EmailId emailId) { - if (_currentEmailId != null && _threadDetailController?.cachedEmailLoaded[_currentEmailId!] != null) { - final emailLoaded = _threadDetailController!.cachedEmailLoaded[_currentEmailId!]!; + if (_currentEmailId != null && _threadDetailController?.cachedEmailLoaded[_currentEmailId] != null) { + final emailLoaded = _threadDetailController!.cachedEmailLoaded[_currentEmailId]!; consumeState(Stream.value(Right(GetEmailContentFromThreadCacheSuccess( htmlEmailContent: emailLoaded.htmlContent, emailCurrent: emailLoaded.emailCurrent, @@ -643,7 +643,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin { void _jumpScrollViewToTopOfEmail() { if (_currentEmailId == null) return; - _threadDetailController?.focusExpandedEmail(_currentEmailId!); + _threadDetailController?.focusExpandedEmail(_currentEmailId); } void _handleUnsubscribe(String listUnsubscribe) { diff --git a/lib/features/mailbox_dashboard/presentation/sentry_ecosystem.dart b/lib/features/mailbox_dashboard/presentation/sentry_ecosystem.dart index d9a5ee639..9fe5e3876 100644 --- a/lib/features/mailbox_dashboard/presentation/sentry_ecosystem.dart +++ b/lib/features/mailbox_dashboard/presentation/sentry_ecosystem.dart @@ -57,9 +57,9 @@ class SentryEcosystem { Future _cacheData(SentryConfig sentryConfig, SentryUser? sentryUser) async { if (_cacheManager == null) return; try { - await _cacheManager!.saveSentryConfiguration(sentryConfig.toSentryConfigurationCache()); + await _cacheManager.saveSentryConfiguration(sentryConfig.toSentryConfigurationCache()); if (sentryUser != null) { - await _cacheManager!.saveSentryUser(sentryUser.toSentryUserCache()); + await _cacheManager.saveSentryUser(sentryUser.toSentryUserCache()); } } catch (e, st) { logError( @@ -68,7 +68,7 @@ class SentryEcosystem { stackTrace: st, ); // Clear both caches to avoid stale/inconsistent state (e.g. new config + old user PII) - await _cacheManager!.clearSentryConfiguration().catchError((_) {}); + await _cacheManager.clearSentryConfiguration().catchError((_) {}); } }