sumValues property
double
get
sumValues
Calculates and returns the sum of all values in the current Map.
The getter uses the reduce method to iterate over the values in the Map.
It accumulates the sum of the values by adding each value to the running total.
The values are converted to double using toDouble() to handle numeric types properly.
Returns the sum of all values as a double.
Example:
Map<String, int> data = {
'A': 10,
'B': 20,
'C': 30,
};
double sum = data.sumValues;
print(sum); // Output: 60.0
Implementation
double get sumValues {
return this.values.reduce((sum, element) => sum + element.toDouble());
}