sumOf<T> function

double sumOf<T>(
  1. List<T> list,
  2. double? getValue(
    1. T elt
    )
)

Utility function to sum up values in a list.

Implementation

double sumOf<T>(List<T> list, double? Function(T elt) getValue) {
  var sum = 0.0;
  for (var elt in list) {
    sum += getValue(elt)!;
  }
  return sum;
}