Flutter & Firebase App Tutorial #4 - Firebase Auth
Why Stack Overflow recommends it
Stack Overflow users link it when answering Flutter questions about checking login state, streaming auth changes, and routing users to the right screen after sign-in.
Recommended by 2 people across 2 different months, 2020 to 2023.
What it is
Part 4 of the Net Ninja's Flutter and Firebase tutorial series, a short screencast that starts building an authentication service class. It sets up sign-in and sign-out handling and implements anonymous sign-in with Firebase Auth.
What people said
Recommends towhid · 2020-10 · Stack Overflow · on “Flutter App gets stuck at loading screen after adding initializing firebase_core”
To check the user's login state you need to implement firebase auth. Follow this tutorial for more detailed view, [this video]
Recommends Hansly · 2023-05 · Stack Overflow · on “How do I handle async authentication verification and navigation with FutureBuilder?”
FutureBuilder and Navigator to me are one-time use auth methods. There's an easy way to make the process go back and forth smoothly: Make a Stream of the authentication state data in the authentication page, then use one Provider to listen to that data in the transition page. For a detailed explanation, you can refer to this video [this video]
Cites ShinMyth · 2022-04 · Stack Overflow · on “How to set up navigation to a specific page base on FirebaseAuth State?”
I'll just assume that you already have a splash screen in place, on that screen you can put the condition for the navigation to HomeScreen or SignInScreen on it's initState() . void initState() { super.initState(); FirebaseAuth.instance.authStateChanges().listen((User? user) { if (user == null) { Navigator.push( context, MaterialPageRoute(builder: (context) => const SignInScreen()), ); } else { Navigator.push( context, MaterialPageRoute(builder: (context) => const HomeScreen()), ); } }); } This solution only shows how to navigate to a specific screen based on user status. What i'll recommend is to create a service file where you gonna put the necessary logic for Flutter Auth. Here's a link t