diff --git a/lib/core/app.dart b/lib/core/app.dart index 76533bb2..ac6071c5 100644 --- a/lib/core/app.dart +++ b/lib/core/app.dart @@ -237,8 +237,10 @@ class _AppState extends State with WidgetsBindingObserver, StringMixin, Cou } /// Configure [ApiClient] with cache + String? token; try { + // fixing this https://github.com/mogol/flutter_secure_storage/issues/43#issuecomment-471642126 token = await _secureStorage.read(SecureStorageKey.token); } catch (e) { _secureStorage.deleteAll(); @@ -248,12 +250,7 @@ class _AppState extends State with WidgetsBindingObserver, StringMixin, Cou _api.accessToken = token; /// Set pin code state - String? pin; - try { - pin = await _secureStorage.read(SecureStorageKey.pin); - } catch (e) { - _secureStorage.deleteAll(); - } + final String? pin = await _secureStorage.read(SecureStorageKey.pin); appState.hasPinCode = token != null && pin != null; appState.pinCode = pin; diff --git a/lib/features/main/main_screen.dart b/lib/features/main/main_screen.dart index e1673cc3..055388d5 100644 --- a/lib/features/main/main_screen.dart +++ b/lib/features/main/main_screen.dart @@ -153,12 +153,7 @@ class _MainScreenState extends State { } else { await SecureStorage.ensureInitialized(); final SecureStorage _secureStorage = SecureStorage(); - String? l; - try { - l = await _secureStorage.read(SecureStorageKey.locale); - } catch (e) { - _secureStorage.deleteAll(); - } + final String? l = await _secureStorage.read(SecureStorageKey.locale); final langCode = l ?? Platform.localeName.substring(0, 2); await FlutterForegroundTask.startService( notificationTitle: diff --git a/lib/main.dart b/lib/main.dart index 22130921..c4159765 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -139,14 +139,7 @@ Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { try { await SecureStorage.ensureInitialized(); final SecureStorage _secureStorage = SecureStorage(); - - String? l; - try { - l = await _secureStorage.read(SecureStorageKey.locale); - } catch (e) { - _secureStorage.deleteAll(); - } - + final l = await _secureStorage.read(SecureStorageKey.locale); final String langCode = l ?? Platform.localeName.substring(0, 2); final PushModel push = PushModel.fromJson(message.data); final Map payload = push.toJson().map((key, value) => MapEntry(key, value?.toString() ?? ''));