count function

int count(
  1. Iterable<num?> iterable
)

Returns the count of values in the iterable.

This function ignores values that do not satisfy any of the following conditions:

  1. The value is not null.
  2. 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;
}