0

I want to get the documents of a few users (in my collection: users). I stored all the ID's that I want in a list.

List shortIDList = [12345, 23425, 32453]

I'm trying this function to get the users from the shortIDList.

 shortIDList.forEach((element) => getFirestoreUsers(st: element));

 getFirestoreUsers({String st}) async {
    await Firestore.instance
        .collection('users')
        .document('$st')
        .get()
        .then((DocumentSnapshot ds) {
      print(ds.data);
   // I would like to add all these documents to a futurebuilder
    });
  }

I would like to add all the documents (to a new list?) That I can use in a futurebuilder, to display all the user information example: profile picture, name etc...

Is that possible?

Thanks!

Constantin Beer
  • 5,447
  • 6
  • 25
  • 43
Karel Debedts
  • 5,226
  • 9
  • 30
  • 70

2 Answers2

1

you are using a list but data is saved by json try using this json format for more see this link click here

Lalit Rawat
  • 1,022
  • 2
  • 17
  • 39
0

I've found the solution:

You can add it to a list.

 myList.add(ds.data);

But you have to define the list:

 List<Map<String, dynamic>> myList = List<Map<String, dynamic>>();

Then it's possible to use it in a futureBuilder

Karel Debedts
  • 5,226
  • 9
  • 30
  • 70