Closed bigzhu closed 1 year ago
You can easily do that by managing the auth status with the Nhost Auth callback to update your app state.
<Your nhost client>.auth
.addAuthStateChangedCallback((authenticationState) {
log('AUTH STATUS CHANGED: ${authenticationState.name}');
_updateLoginStatus();
});
it takes less than a second for the callback to execute. You can wait for it during a splash screen.
You can use the .signInWithStoredCredentials()
method on the initial load to ensure the user can log in. Please make sure to catch an error, as this method throw an exception if a silent log in is not possible.
nhostClient.auth
.signInWithStoredCredentials()
.then((value) {print('user is signed in $value'})
.catchError(print);
When APP reopen, always need login, it's so silly.