get all documents in collection firestore flutter

Solutions on MaxInterview for get all documents in collection firestore flutter by the best coders in the world

showing results for - "get all documents in collection firestore flutter"
Erik
15 Oct 2019
1final _fireStore = FirebaseFirestore.instance;
2Future<void> getData() async {
3    // Get docs from collection reference
4    QuerySnapshot querySnapshot = await _fireStore.collection('collectionName').get();;
5
6    // Get data from docs and convert map to List
7    final allData = querySnapshot.docs.map((doc) => doc.data()).toList();
8  //for a specific field
9  final allData =
10          querySnapshot.docs.map((doc) => doc.get('fieldName')).toList();
11
12    print(allData);
13}
14