Im trying to store querysnapshot document into a local list but for some reason the its not working here is the way i did it

Viewed 28

I want to the doc[uid] results into the _following list to use somewhere else but its not working

'''

List _followingList = [];

FirebaseFirestore.instance

    .collection('venues')
    .where('followers', arrayContains: user.uid)
    .get()
    .then((QuerySnapshot querySnapshot) {
  querySnapshot.docs.forEach((doc) {
  
    setState(() {
      _followingList.add(doc['uid']);
    });
  });
});

'''

1 Answers

You dont need to use setState here. So, use this line without wrapping it in a setState()

  querySnapshot.docs.forEach((doc) {
      _followingList.add(doc['uid']);
  });
Related