I'm trying to waitUser(array) check exist value how can I?
// if waitUser array field exist 2 return text("this text") else return text("other text")
body: StreamBuilder(
stream: FirebaseFirestore.instance
.collection('events')
.where('eventCity', isEqualTo: 'Ankara')
.snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
// ERROR
return Center(
child: CircularProgressIndicator(),
);
} else {
return Container(
child: ListView(
scrollDirection: Axis.vertical,
children: snapshot.data.docs.map((document) {
// if waitUser array field exist 2 return text("this text") else return text("other text")
}).toList(),
),
);
}
},
),
In the else portion of your builder do this:
This will gather each document that meets your criteria of
eventCity == "Ankara"
. For each of those documents, it will check thewaitUser
array for "2". If "2" exists in the array, it will returntext("this text")
; otherwise, it will returntext("other text")
.