skip to Main Content

Firebase – How to loop through Instance of '_MapStream<QuerySnapshotPlatform, QuerySnapshot<Map<String, dynamic>>>'?

static List categoryList() { final categorySnapshots = FirebaseFirestore.instance .collection('categories') .orderBy('name') .snapshots(); List categories = []; categorySnapshots.map((snapshot) => snapshot.docs.map((doc) { print(snapshot.toString()); categories.add(doc.data()['name']); })); print(categories); return categories; } Categories is empty. How to populate it with the data from snapshots?

VIEW QUESTION
Back To Top
Search