Fix navigation error when state is changed to denied at app first start [skip_ci]

This commit is contained in:
OmarHatem 2022-12-03 23:34:23 +02:00
parent ffd0079e1d
commit 11a5e97711
3 changed files with 6 additions and 6 deletions

View file

@ -261,7 +261,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
final statusBarColor = Colors.transparent;
final authenticationStore = getIt.get<AuthenticationStore>();
final initialRoute =
authenticationStore.state == AuthenticationState.denied
authenticationStore.state == AuthenticationState.uninitialized
? Routes.disclaimer
: Routes.login;
final currentTheme = settingsStore.currentTheme;

View file

@ -22,9 +22,9 @@ Future<void> bootstrap(GlobalKey<NavigatorState> navigatorKey) async {
final currentWalletName = getIt
.get<SharedPreferences>()
.getString(PreferencesKey.currentWalletName);
authenticationStore.state = currentWalletName == null
? AuthenticationState.denied
: AuthenticationState.installed;
if (currentWalletName != null) {
authenticationStore.state = AuthenticationState.installed;
}
startAuthenticationStateChange(authenticationStore, navigatorKey);
startCurrentWalletChangeReaction(

View file

@ -23,12 +23,12 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
}
if (state == AuthenticationState.allowed) {
await navigatorKey.currentState?.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
return;
}
if (state == AuthenticationState.denied) {
await navigatorKey.currentState?.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
return;
}
});