minor context check

Omar committed May 5, 2026 at 23:03 UTC 8e7d4485ac21d796aa9c6d5ce384633fa6b47ec2
1 file changed +43 -44
lib/core/auth_service.dart
+43 -44
@@ -96,8 +96,7 @@ class AuthService with Store {
96 }
97
98 // Check for duress pin
99 - final duressKey =
100 - generateStoreKeyFor(key: SecretStoreKey.duressPinCodePassword);
99 + final duressKey = generateStoreKeyFor(key: SecretStoreKey.duressPinCodePassword);
100 final encodedDuressPin = await secureStorage.read(key: duressKey);
101
102 String? decodedDuressPin;
@@ -110,12 +109,12 @@ class AuthService with Store {
109 }
110
111 if (decodedDuressPin == pin) {
113 - await _handleDuressLogin(secureStorage, sharedPreferences,
114 - authenticationStore, appStore, resetService, walletList);
112 + await _handleDuressLogin(secureStorage, sharedPreferences, authenticationStore, appStore,
113 + resetService, walletList);
114
115 navigatorKey.currentState?.pushNamedAndRemoveUntil(
116 Routes.welcome,
118 - (route) => false,
117 + (route) => false,
118 );
119
120 return false;
@@ -167,52 +166,53 @@ class AuthService with Store {
166 }
167 }
168
170 - Navigator.of(context).pushNamed(Routes.auth,
171 - arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) async {
172 - if (!isAuthenticatedSuccessfully) {
173 - onAuthSuccess?.call(false);
174 - return;
175 - } else {
176 - if (settingsStore.useTOTP2FA && conditionToDetermineIfToUse2FA) {
177 - auth.close(
178 - route: Routes.totpAuthCodePage,
179 - arguments: TotpAuthArgumentsModel(
180 - isForSetup: !settingsStore.useTOTP2FA,
181 - onTotpAuthenticationFinished:
182 - (bool isAuthenticatedSuccessfully, TotpAuthCodePageState totpAuth) async {
183 - if (!isAuthenticatedSuccessfully) {
184 - onAuthSuccess?.call(false);
185 - return;
186 - }
187 - if (onAuthSuccess != null) {
188 - totpAuth.close().then((value) => onAuthSuccess.call(true));
189 - } else {
190 - totpAuth.close(route: route, arguments: arguments);
191 - }
192 - },
193 - ),
194 - );
169 + if (context.mounted) {
170 + Navigator.of(context).pushNamed(Routes.auth,
171 + arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) async {
172 + if (!isAuthenticatedSuccessfully) {
173 + onAuthSuccess?.call(false);
174 + return;
175 } else {
196 - if (onAuthSuccess != null) {
197 - auth.close().then((value) => onAuthSuccess.call(true));
176 + if (settingsStore.useTOTP2FA && conditionToDetermineIfToUse2FA) {
177 + auth.close(
178 + route: Routes.totpAuthCodePage,
179 + arguments: TotpAuthArgumentsModel(
180 + isForSetup: !settingsStore.useTOTP2FA,
181 + onTotpAuthenticationFinished:
182 + (bool isAuthenticatedSuccessfully, TotpAuthCodePageState totpAuth) async {
183 + if (!isAuthenticatedSuccessfully) {
184 + onAuthSuccess?.call(false);
185 + return;
186 + }
187 + if (onAuthSuccess != null) {
188 + totpAuth.close().then((value) => onAuthSuccess.call(true));
189 + } else {
190 + totpAuth.close(route: route, arguments: arguments);
191 + }
192 + },
193 + ),
194 + );
195 } else {
199 - auth.close(route: route, arguments: arguments);
196 + if (onAuthSuccess != null) {
197 + auth.close().then((value) => onAuthSuccess.call(true));
198 + } else {
199 + auth.close(route: route, arguments: arguments);
200 + }
201 }
202 }
202 - }
203 - });
203 + });
204 + }
205 }
206 }
207
207 -
208 Future<void> _handleDuressLogin(
209 - SecureStorage secureStorage,
210 - SharedPreferences sharedPreferences,
211 - AuthenticationStore authenticationStore,
212 - AppStore appStore,
213 - ResetService resetService,
214 - List<WalletInfo> wallets,
215 - ) async {
209 + SecureStorage secureStorage,
210 + SharedPreferences sharedPreferences,
211 + AuthenticationStore authenticationStore,
212 + AppStore appStore,
213 + ResetService resetService,
214 + List<WalletInfo> wallets,
215 +) async {
216 printV('[DURESS] START FULL WIPE PROCESS');
217
218 // Close wallet instance if opened
@@ -278,4 +278,3 @@ Future<void> _handleDuressLogin(
278
279 printV('[DURESS] FULL WIPE COMPLETED');
280 }
281 -