Skip to content

Commit

Permalink
fix(android)!: error caused endless loading on launch
Browse files Browse the repository at this point in the history
- forgot setState on the future so the error widget didnt show.
- the error came from a bug in secure_storage after backup restore.
mogol/flutter_secure_storage#354
- this fix causes all android users to get signed out once
  • Loading branch information
andreasgangso committed May 3, 2023
1 parent 25c3ae7 commit f636532
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ android {

defaultConfig {
applicationId "tv.brunstad.app"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ import '../../../models/auth0/auth0_id_token.dart';
import '../../../models/auth_state.dart';
import '../auth_state.dart';

// Careful. This line is very important,
// Careful. The function naming here is very important,
// but because it's conditionally imported (see auth_state_notifier_interface.dart)
// IDEs don't show any errors when you remove it..
AuthStateNotifier getPlatformSpecificAuthStateNotifier(Ref ref) => AuthStateNotifierMobile(
appAuth: const FlutterAppAuth(),
secureStorage: const FlutterSecureStorage(),
settingsService: ref.watch(settingsProvider.notifier),
);
// IDEs don't show any errors when you remove/change it..
AuthStateNotifier getPlatformSpecificAuthStateNotifier(Ref ref) {
return AuthStateNotifierMobile(
appAuth: const FlutterAppAuth(),
secureStorage: const FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true, // https://github.com/mogol/flutter_secure_storage/issues/354
sharedPreferencesName: 'auth',
),
),
settingsService: ref.watch(settingsProvider.notifier),
);
}

const kMinimumCredentialsTTL = Duration(hours: 1);

Expand Down
4 changes: 3 additions & 1 deletion lib/screens/auto_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class _AutoLoginScreeenState extends ConsumerState<AutoLoginScreen> {

void load() async {
final deepLinkUri = await AppLinks().getInitialAppLink();
authFuture = ref.read(authStateProvider.notifier).load();
setState(() {
authFuture = ref.read(authStateProvider.notifier).load();
});
authFuture!.then((_) {
debugPrint('navigate(deepLinkUri: $deepLinkUri)');
navigate(deepLinkUri: deepLinkUri);
Expand Down

0 comments on commit f636532

Please sign in to comment.