Reputation: 133
I may missunderstand something.
_thisEvent.eventKidsPayed is a List that contains documentID strings. kidsSnapshot.data.documents[index].documentID will give us a string.
_thisEvent.eventKidsPayed is currently EMPTY there is nothing in the list.
bool _payed = false;
if (_thisEvent.eventKidsPayed.contains(kidsSnapshot
.data.documents[index].documentID)) {
_payed = true;
}
It's always returning true. Why ?
Upvotes: 0
Views: 571
Reputation: 133
The problem was with my Insert and Delete and not with my .contains Sorry all for disturbing and time lost.
I was doing this by error (this is not the code but the logic)
If(value) //true if contains
array remove
else
array union
So it was totally wrong, I fixed doing If(!value). Sorry for this.
Upvotes: 0
Reputation: 1451
You need to use setState
to change bool. Follow the below code. You need to use StatefulWidget
for using setState
.
bool _payed = false;
if (_thisEvent.eventKidsPayed.contains(kidsSnapshot
.data.documents[index].documentID)) {
setState(() {
_payed = true;
});
}
Upvotes: 1