I am using Firebase Authentication on my Flutter Web app, but the session is not persisted during refresh.
This is the package I am using.
https://pub.dev/packages/firebase
This is how I am authenticating with Firebase
static Future<User> handleSignInEmail(String email, String password) async {
await init();
final UserCredential userCredential =
await auth().signInWithEmailAndPassword(email.trim(), password);
assert(userCredential.user != null);
assert(await userCredential.user.getIdToken() != null);
final User currentUser = await userCredential.user;
assert(userCredential.user.uid == currentUser.uid);
print('signInEmail succeeded: $userCredential.user');
return userCredential.user;
}
If I refresh the page and call the following method, the user that is returned is null:
static Future<User> getFirebaseUser() async {
await init();
return await auth().currentUser;
}
A similar implementation using Flutter Mobile works as expected. What am I missing on the Flutter Web implementation?