Reputation: 798
I have collection for Users and groups, I want to display list of last update groups. But, the user must be stay in member list of groupCollection.
There is a screenshot of group collection
So, I used StreamBuilder
StreamBuilder(
stream: FirebaseFirestore.instance
.collection("groups")
.orderBy('LastUpdate', descending: true)
.where(
"members",
isEqualTo: FirebaseAuth.instance.currentUser!.uid,
)
.snapshots(),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
if (snapshot.data['members'] != null) {
if (snapshot.data['members'].length != 0) {
return Padding(
padding: const EdgeInsets.only(top: 5),
child: ListView.builder(
itemCount: snapshot.data['members'].length,
itemBuilder: (context, index) {
return Text(
snapshot.data["groupName"],
);
},
),
);
} else {
return noGroupWidget();
}
} else {
return noGroupWidget();
}
} else {
return Center(
child: CircularProgressIndicator(color: Colors.white),
);
}
});
This showing always white color CircularProgressIndicator
Upvotes: 0
Views: 217
Reputation: 599926
You're ignoring errors. When dealing with any AsyncSnapshot
, always check for errors. For example with:
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasError) {
return Text('${snapshot.error}');
}
if (snapshot.hasData) {
...
This will tell you the root cause of the problem.
Upvotes: 2