The `every` method in Dart checks whether every element of this iterable satisfies a given test function.
The syntax of Runes.every() method is:
bool every(bool test(int element))
This every() method of Runes checks whether every element of this iterable satisfies test
.
Parameter | Optional/Required | Description |
---|---|---|
test | required | A function that takes an integer element as input and returns a boolean value indicating whether the element satisfies the test. |
Runes.every() returns value of type bool
.
In this example,
runes
from the string 'Hello'.every
method with a test function to check if all characters are lowercase.void main() {
Runes runes = Runes('Hello');
bool allLowerCase = runes.every((element) => element >= 97 && element <= 122);
print('Are all characters lowercase? $allLowerCase');
}
Are all characters lowercase? false
In this example,
numbers
from the string '12345'.every
method with a test function to check if all elements are digit characters.void main() {
Runes numbers = Runes('12345');
bool allDigits = numbers.every((element) => element >= 48 && element <= 57);
print('Are all elements digits? $allDigits');
}
Are all elements digits? true
In this Dart tutorial, we learned about every() method of Runes: the syntax and few working examples with output and detailed explanation for each example.