count method

int count(
  1. bool predicate(
    1. E element
    )
)

Returns the number of time predicate evaluates to true.

The following expression yields 2, because there are 2 odd numbers:

[1, 2, 3].count((element) => element.isOdd);

Implementation

int count(bool Function(E element) predicate) => where(predicate).length;