Reputation:
IM trying to figuring out if a document exist . I wanna do that with the streambuilder to change methods if its exist. Heres how im trying
StreamBuilder(
stream: FirebaseFirestore.instance
.collection("videos")
.doc(videos.data()['id'])
.collection("uservotes")
.doc(uid)
.snapshots(),
builder: (context, sasapshot) {
if (sasapshot.connectionState ==
ConnectionState.waiting) {
return CircularProgressIndicator();
} else {
mainAxisAlignment:
MainAxisAlignment.end,
children: [
Container(
So the doc videos.data()['id'] is a video . The stream is wrapped with a stream and from there im gettin the curretn video . The current video can change because the 2 streams are wrapped with PageView.builder . Is what I want now is checking if these collection uservotes has the uid of the curretn user inside. so the uid. And on scrolling PageView I check that for each video . Hope thats clear. So my question is how can I do that ? Checking if the uid as document exist in uservotes subcolletion, with the stream?
Upvotes: 2
Views: 704
Reputation: 12353
You can use exists
property.
if (snapshot.data.exists) {
//return logic if the document exists based on uid
}
Upvotes: 4