countWhere method

int countWhere(
  1. bool predicate(
    1. T element
    )
)

Returns the count of elements that match the given predicate.

Example:

Iterable<int>? numbers = [1, 2, 3, 4, 5];
int count = numbers.countWhere((number) => number > 3);  // 2

Implementation

int countWhere(bool Function(T element) predicate) {
  if (isNullOrEmpty) return 0;
  return this!.where(predicate).length;
}