When something is added to the stream the Stream Provider is not notifying the other providers which is causing the UI to remain unchanged / on a loading screen.
class Home extends StatelessWidget {
final String uid;
Home(this.uid,);
@override
Widget build(BuildContext context) {
return StreamProvider<QuerySnapshot?>.value(
value: DatabaseServices(uid: uid).currentUserData,
initialData: null,
updateShouldNotify: (_, __) => true,
child: BottomBar());
}
}
class TrackerWrapper extends StatelessWidget {
bool notLoaded = true;
bool todayDone = false;
bool remote = false;
@override
Widget build(BuildContext context) {
final days = Provider.of<QuerySnapshot?>(context);
if(days != null){
for (var doc in days.docs){
if(doc.id == DateFormat.yMMMEd().format(DateTime.now())){
todayDone = true;
if(doc.get('type') == "Remote"){
remote = true;
}
break;
}
}
notLoaded = false;
}
return notLoaded? Loading() : todayDone? remote? RemoteReport() : OnSiteReport() : Tracking();
}
}
SignUp class extract
if(isEmail(_email.text) && isPassword(_password.text, _password2.text) && !errorAge && !errorLastName && !errorName){
setState(() {
loading = false;
});
CurrentUser? user = await auth.createUserEmailAndPassword(_email.text, _password.text);
if(user == null){
setState(() {
errorHasAccount = true;
});
}
else{
errorHasAccount = false;
Navigator.pop(context, 'SignIN');
Navigator.push(context, MaterialPageRoute(
builder: (context) => Home(user.uid)));
}
}
When a user created an account the Home widget should locate the user in the database and show a loading screen while doing this. When it locates the user it will decide what screen to show depending on the users data. However the screen remains on loading when an account is created unless i run a hot restart. When hot restart is ran it the correct screen is shown.
I'm not sure why changes in the stream aren't triggering a update of state automatically.
Tried setting state on a timer and adding updateShouldNotify: (_, __) => true,