Your code is generally on the right track, I made small tweaks for you but as your code is now, you should be fine -
StreamBuilder(
stream: FirebaseFirestore.instance
.collection("ADS")
.doc(widget.selectedAds?['Uid'] ?? "")
.collection("REQUESTS")
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
final passengerId = snapshot.data!.docs[index].get("UID");
if (passengerId == uid) {
return Text(
"Request already sent",
style: TextStyle(color: Colors.white),
);
} else {
return Text(
"Send a request",
style: TextStyle(color: Colors.white),
);
}
},
);
} else {
return Text(
"No data found",
style: TextStyle(color: Colors.white),
);
}
},
)