title: How can I get some data from firestore and sumarize it?
body: <p>i want to get some data from fireabse and then sum up them.
  In cloud firestore i have a collection, where i save meals with some extra datas(like: name, calories, protein, fat, date etc.)
  I would like to receive the data for 1 day and sumarize it, but when I print it, I get a null value.</p>
  <p>This is the code:</p>
  <pre><code>     class _MealTrackState extends State&lt;MealTrack&gt; {
        List&lt;double&gt; calories = [];
        var sumCalories;
      
        Future&lt;void&gt; getCalories(DateTime dateTime)  {
          DateTime _start = DateTime(dateTime.year,dateTime.month,dateTime.day,0, 0, );
          DateTime _end = DateTime(dateTime.year,dateTime.month,dateTime.day, 23,59,59, );
      
          Stream &lt;QuerySnapshot&gt; snapshot =  firestore.collection('savedMelas').where('date',isGreaterThanOrEqualTo: _start)
              .where('date', isLessThanOrEqualTo: _end).snapshots();
          snapshot.forEach((field) {
            field.docs.asMap().forEach((index, data) {
              calories.add(field.docs[index]['calories'].toDouble());
            });
            setState(() {
              sumCalories = calories.reduce((a,b) =&gt;a+b);
            });
          });
        }
  @override
    initState() {
      super.initState();
      getCalories(widget.date);
    }
  .
  .
  .
  }
  </code></pre>
  <p>What do I do wrong? Please help!</p>