From ba28e09e58f17677310c098e605947b82e631c31 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Fri, 2 Jan 2026 15:28:26 -0500 Subject: [PATCH] downgrade `flutter_secure_storage`, safer async ops potential fix for #484 --- lib/main.dart | 14 +++++++++++--- pubspec.lock | 44 ++++++++++++++++++++++++++------------------ pubspec.yaml | 2 +- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 59ad27ed..46a6e08b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,11 +54,16 @@ void main() async { // Workaround for clearing stored tokens on uninstall. // If first time running app, will clear all tokens in the secure storage. + // Run non-blocking to avoid ANR on slow Android devices (especially Android 14). if (firstRun) { debugPrint('Clearing secure storage...'); const storage = FlutterSecureStorage(); - await storage.deleteAll(); + // Don't block - run in background after app starts. + // This is safe because first run means no active session depends on this data. + unawaited(storage.deleteAll().catchError((e) { + debugPrint('Error clearing secure storage: $e'); + })); } await initUtils(); @@ -183,8 +188,11 @@ class _MyAppState extends State { handleDeepLink(uri); }); - // Handle the initial link if app was opened from a link - final initialLink = await _appLinks.getInitialLink(); + // Handle the initial link if app was opened from a link. + // Add timeout to prevent indefinite blocking on certain Android lifecycle states. + final initialLink = await _appLinks + .getInitialLink() + .timeout(const Duration(seconds: 3), onTimeout: () => null); if (initialLink != null) { handleDeepLink(initialLink); } diff --git a/pubspec.lock b/pubspec.lock index 898b2989..ec8c083a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -490,50 +490,50 @@ packages: dependency: "direct main" description: name: flutter_secure_storage - sha256: da922f2aab2d733db7e011a6bcc4a825b844892d4edd6df83ff156b09a9b2e40 + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" url: "https://pub.dev" source: hosted - version: "10.0.0" - flutter_secure_storage_darwin: - dependency: transitive - description: - name: flutter_secure_storage_darwin - sha256: "8878c25136a79def1668c75985e8e193d9d7d095453ec28730da0315dc69aee3" - url: "https://pub.dev" - source: hosted - version: "0.2.0" + version: "9.2.4" flutter_secure_storage_linux: dependency: transitive description: name: flutter_secure_storage_linux - sha256: "2b5c76dce569ab752d55a1cee6a2242bcc11fdba927078fb88c503f150767cda" + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "1.2.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247" + url: "https://pub.dev" + source: hosted + version: "3.1.3" flutter_secure_storage_platform_interface: dependency: transitive description: name: flutter_secure_storage_platform_interface - sha256: "8ceea1223bee3c6ac1a22dabd8feefc550e4729b3675de4b5900f55afcb435d6" + sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "1.1.2" flutter_secure_storage_web: dependency: transitive description: name: flutter_secure_storage_web - sha256: "6a1137df62b84b54261dca582c1c09ea72f4f9a4b2fcee21b025964132d5d0c3" + sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "1.2.1" flutter_secure_storage_windows: dependency: transitive description: name: flutter_secure_storage_windows - sha256: "3b7c8e068875dfd46719ff57c90d8c459c87f2302ed6b00ff006b3c9fcad1613" + sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709 url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "3.1.2" flutter_svg: dependency: "direct main" description: @@ -648,6 +648,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" json_annotation: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 40234a08..49a91e70 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 web_socket_channel: ^3.0.0 - flutter_secure_storage: ^10.0.0 + flutter_secure_storage: ^9.2.2 intl: ^0.20.1 cached_network_image: ^3.1.0 webview_flutter: ^4.2.0