I have returned all the IDs of my firestore documents, and now I need to get the index of each one. Until now I get an error: "Spread elements in a list or set literals must implement 'Iterable' " So, How can I iterate over it?
FirebaseFirestore.instance
.collection('prova')
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
print(doc.id);
//this next line gives me error
var a = <String>{...doc.id};
print(a);
});
});
Output:
I/flutter (29392): G0luyVnh1ahW5bfSqh8k
I/flutter (29392): V7ts6hEYqQiM4creal1O
I/flutter (29392): Xf3zzLzBzF3dzQ4OT9oO
I/flutter (29392): iKSjc3HQCAvzmaCMpFcg
I/flutter (29392): jxHT2TwMTfRf8SjbidK2