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 statusBarColor = Colors.transparent;
final authenticationStore = getIt.get<AuthenticationStore>(); final authenticationStore = getIt.get<AuthenticationStore>();
final initialRoute = final initialRoute =
authenticationStore.state == AuthenticationState.denied authenticationStore.state == AuthenticationState.uninitialized
? Routes.disclaimer ? Routes.disclaimer
: Routes.login; : Routes.login;
final currentTheme = settingsStore.currentTheme; final currentTheme = settingsStore.currentTheme;

View file

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

View file

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