how to sum values of a field inside a firestore collection related to another collection in flutter 2.0


I’m a little lost here, I’m trying to get the sum of a specific field, my code here:

Future _sumCarta() async {
    await _firebaseServices.usersRef
        .then((querySnapshot) { async {
        // here I want to sum
         num value =["price"];

I want to get the sum result of all documents, any help or ideas are welcome, thank you


Wouldn’t that be:

num sum = 0.0; async {
  num value =["price"];
  sum = sum + value;

Answered By – Frank van Puffelen

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *