every method
- bool test(
- E element
override
Checks whether every element of this iterable satisfies test
.
Checks every element in iteration order, and returns false
if
any of them make test
return false
, otherwise returns true
.
Returns true
if the iterable is empty.
Example:
final planetsByMass = <double, String>{0.06: 'Mercury', 0.81: 'Venus',
0.11: 'Mars'};
// Checks whether all keys are smaller than 1.
final every = planetsByMass.keys.every((key) => key < 1.0); // true
Implementation
bool every(bool test(E element)) {
int length = this.length;
for (int i = 0; i < length; i++) {
if (!test(this[i])) return false;
if (length != this.length) {
throw ConcurrentModificationError(this);
}
}
return true;
}