Question : how to sum up the list of values in a list of map
Answered by : godwin-mathias
void main(){ var data = [{"Title": "product 1", "Item Score": 87.3, "Characters": 72, "Image Count": 6}, {"Title": "product 2", "Item Score": 85.1, "Characters": 56, "Image Count": 2}]; double totalScores = 0.0; // looping over data array data.forEach((item){ //getting the key direectly from the name of the key totalScores += item["Item Score"]; }); print(totalScores); // OUTPUT ==> 172.39999999999998
}
Source : https://stackoverflow.com/questions/63455765/finding-the-sum-of-all-values-in-a-list-of-maps-in-flutter | Last Update : Fri, 19 Aug 22