-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
Instead of saving that the user is logged in with Shared Preferences, you can check Firebase Auth directly if the user is logged in/signed up. It is not better or worse. I personally just think its a bit better and cooler to directly check the Firebase Auth. Here is the code if you want to implement it:
StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else if (snapshot.hasData) {
return NavBar();
} else if (snapshot.hasError) {
return Center(
child: Text('Something has gone Wrong'),
);
} else {
return logInPage(context);
}
},
),
Metadata
Metadata
Assignees
Labels
No labels