Reputation: 9119
I have a user follow/unfollow page that searches Firebase for a list of followers and returns a Boolean if their usedID is found...
Future<Null> _friends() async {
fb.child("users/${userid}/Following/${id}").onValue.listen((Event event) {
setState((){
if (event.snapshot.value != null) {
friends == true;
} else if (event.snapshot.value == null) {
friends == false;
}
});
});
}
The bool is then set in a separate function that changes a public bool...
bool friends;
The trouble is that my Widget/Scaffold doesn't update here...
friends == true ? new RaisedButton(onPressed: unfollow()) :
new RaisedButton(onPressed: follow());
Any ideas? I'll update with exact code once later.
Upvotes: 0
Views: 1612
Reputation: 409
the issue is that you've used an ==
(equality) comparison operator instead of =
(assignment). Change your code to the following:
Future<Null> _friends() async {
fb.child("users/${userid}/Following/${id}").onValue.listen((Event event) {
setState((){
// this will return true or false which is what you want based on your code :)
friends = event.snapshot.value == null;
});
});
}
Upvotes: 1