sum method

T sum()

Extension method for Iterable

int sumInt = [1, 2, 3].sum();
print(sumInt);

double sumDouble = [1.0, 2.0, 3.0].sum();
print(sumDouble);

Implementation

T sum() => reduce((value, element) => (value + element) as T);