The StreamBuilder Widget doesn't update the UI ,i still always see the ChoiceScreen which contains two buttons Log In and Sign Up when i click Sign Up it takes me to the SignUpSCreen , pretty same for the LoginScreen , But when i try to Login as a registred User the StreamBuilder doesn't update the Ui and show the ChatScreen widget unless i re-run the application or do a Hot restart to see the updated UI .
Here's what i tried :
StreamBuilder(
stream: FirebaseAuth.instance.onAuthStateChanged,
builder: (context, userSnap){
print('stream builder');
// a valid token
if(userSnap.hasData){
print('valid token .. user logged in');
return ChatScreen();
}
print('not yet');
return ChoiceScreen();
},
),
The logic seems working , i got :
I/flutter ( 5194): stream builder
I/flutter ( 5194): valid token .. user logged in
But it doesn't return the screen i'm expecting ... and i should do Hot restart to see it ,as i mentioned .
I tried this but the problem persist ..
Any suggestions or advice would be appreciated. Thanks.