total property
int
get
total
Calculates the total sum of the integers in the iterable.
- Returns
0if the iterable isnullor empty. - Null elements within the iterable are treated as
0.
Example:
Iterable<int?>? numbers = [1, 2, null, 4];
int sum = numbers.total; // sum is 7
Implementation
int get total {
if (isEmptyOrNull) return 0;
var sum = 0;
for (final current in this!) {
sum += current ?? 0;
}
return sum;
}