count function
Returns the count of values in the iterable.
This function ignores values that do not satisfy any of the following conditions:
- The value is not
null. - The value is not double.nan.
For example:
count([double.nan, 18, null]); // 1
If the iterable is empty or contains no valid values, this function
returns 0.
Implementation
int count(Iterable<num?> iterable) {
var count = 0;
for (final value in iterable) {
if (value != null && value == value) count++;
}
return count;
}