I have an auth check screen setup with a builder listening to authStateChanges() and to hopefully update the screen and show the home page when the user logs in. I’ve tried messing with the auth check, which is my main suspicion, and also with the login and log out functions. I do not know what else to do, any help is appreciated.
@override //this is a stateful widget btw
Widget build(BuildContext context) {
return StreamBuilder<User?>(
stream: AuthHelper().authStateChanges, // just a getter for FirebaseAuth.instance.authStateChanges()
builder: (context, snapshot) {
return snapshot.hasData
? const HomeScreenLayout()
: const LoginOptionsScreen();
},
);
}
And this is what the button looks like:
StandardButton(
...,
onTap: () {
AuthHelper().signInWithEmail(
email: userEmail.text.trim(),
password: password.text.trim(),
);
},
),
// the method inside AuthHelper class
Future<void> signInWithEmail({email, password}) async {
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
}
The problem is that after inputting the correct login info, and pressing the button, the screen that should otherwise update, does not. I have to hot restart the app every time to see the changes.
The weird part is that the sign out function for the same class, working with the exact same button in the home screen, does work properly and redirects me to the login page automatically
StandardButton(
...,
onTap: () {
AuthHelper().signOut();
},
),
// the method inside AuthHelper class
Future<void> signOut() async {
await _firebaseInstance.signOut();
}
de_void is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.