Routing to another screen when I create user with email and password #4021
Unanswered
ghost
asked this question in
Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I login, it is routing to Home Screen from Login Screen.
But when I register, it is not routing to Home Screen.
I used �FutureBuilder Widget for streaming auth state changes.
Here is my code, Please let me know what I should fix.
@OverRide
Widget build(BuildContext context) {
return FutureBuilder(
future: _initialization,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return CircularProgressIndicator();
}
if (snapshot.hasError) {
return Scaffold(body: Center(child: Text(snapshot.error)));
}
if (snapshot.connectionState == ConnectionState.done) {
return StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
User user = snapshot.data;
print(user);
if (user == null) {
return LoginScreen();
} else {
return HomeScreen();
}
}
return Scaffold(
body: Center(child: Text("Checking Authentication"))
);
}
);
}
return Scaffold(body: Center(child: Text("Connecting User")));
}
);
Beta Was this translation helpful? Give feedback.
All reactions