return ListView(
children:
snapshot.data!.docs.map((DocumentSnapshot document) {
Map<String, dynamic> data =
document.data()! as Map<String, dynamic>;
// setState(() {
// allCalWorkout += data['totalCal'];
// });
return Container(
margin: EdgeInsets.all(20),
child: ListTile(
onTap: () {},
title: Text(data['nameWorkout']),
subtitle: Text(
'set: ${data['set']} calories:${data['totalCal']}'),
trailing: IconButton(
onPressed: () async {
// print(document.id);
await delWorkout(document.id);
setState(() {
_workout = getAllWorkout();
});
},
icon: Icon(Icons.delete, color: Colors.red))),
);
}).toList());
I want to sum all the calories in firebase name is "totalCal" and also how to store the total variable for passing to another page.