Hi I'm working on flutter project for my study. I use Firebase to make a login system in my app. Below code is my RootPage in my app. I have problem in refreshing the user information. When there is no user displayName, then rootpage move to InputPage and I can input name. However, when I finish inputting name and updateDiplayName, it does not move to TapPage directly. I searched in stackoverflow and I add reload method but still not working. Can you give me some advice? By the way, last code is InputPage's trigger part.
Widget build(BuildContext context) {
return StreamBuilder<User>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot){
if(!snapshot.hasData){
return LoginPage();
}
snapshot.data.reload();
if(!snapshot.data.emailVerified){
return EmailPage(snapshot.data);
}
if(snapshot.data.displayName==null){
return InputPage(snapshot.data);
}
return TabPage(snapshot.data);
}
);
}
onPressed: () {
Navigator.pop(context); //this is alert dialog
widget.user.updateDisplayName(_nameController.text);
widget.user.reload();
Navigator.push(context, MaterialPageRoute(builder: (context) {
return TabPage(widget.user);
}));
},