How to get particular data from List<Object> in flutter

Viewed 22

Im getting data using querysnapshot in my flutter project. But can not print all the name from the List.

My code :

    var collectionRef = FirebaseFirestore.instance.collection("users") .where("role", 
    isEqualTo: "Student");

    Future<void> getData() async {
      // Get docs from collection reference
      QuerySnapshot querySnapshot = await collectionRef.get();
      // Get data from docs and convert map to List
      final allData = querySnapshot.docs.map((doc) => doc.data()).toList();

      print(allData.runtimeType);

      for (var data in allData){
        print(data['name']);
      }

response from firebase

0 Answers
Related