'Flutter how to access each field of of doc

I am new to Flutter and I want to extract each field of each doc in order to manipulate the data.

This is the code for the extraction from the Firebase Firestore

Future<void> queryBasedOnDrug(
  String nameOfThePharmacy, String nameOfTheDrug) async {
var docSnapshot = await firestoreInstance
    .collection('Pharmacies')
    .doc(nameOfThePharmacy)
    .collection('Drugs')
    .where('Name', isEqualTo: nameOfTheDrug)
    .get()
    .then((querySnapshot) {
  querySnapshot.docs.forEach((result) {
    print(result.data());
  });
});

}

And this is the output, as you can see I have two docs that correspond to my query, and for each doc, I want to extract /access each field. enter image description here It is possible? If so How can I do that?

I search online but the things I found did not fix my problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source