The any()
method can be used to check if at least one item in a List
satisfies the condition.
bool any(bool test(E element));
The following code shows how to use the any()
method in dart:
void main(){// Creating listList numbers = [9, 5, 8, 17, 11, 15, 23];// Using any()// verify if at least one item in the list is greater than 7if (numbers.any((item) => item > 7)) {// Print resultprint('At least one number > 7 in the list');}}