count method
Returns the number of elements matching the given predicate
.
If no predicate
is given, this equals to length.
Implementation
int count([bool Function(E element)? predicate]) {
var count = 0;
if (predicate == null) {
return length;
} else {
for (var current in this) {
if (predicate(current)) {
count++;
}
}
}
return count;
}