all method
Checks whether all elements of this iterable satisfy test
.
Iterates through each element, returning false
as soon as an element
does not satisfy test
. Returns true
if all elements satisfy test
.
Returns true
if the iterable is empty (since no elements violate the condition).
Example:
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.all((element) => element >= 5); // false;
result = numbers.all((element) => element >= 0); // true;
Implementation
bool all(ConditionTester<T> test) {
for (T element in this) {
if (!test(element)) return false;
}
return true;
}