countWhere method

int countWhere(
  1. bool test(
    1. E element
    )
)

Returns the number of elements that satisfy test.

Example:

[1, 2, 3, 4].countWhere((n) => n.isEven); // 2

Implementation

int countWhere(bool Function(E element) test) {
  int count = 0;
  for (final E element in this) {
    if (test(element)) {
      count++;
    }
  }
  return count;
}