What is the List.any() method in Dart?
Overview
The any() method can be used to check if at least one item in a List satisfies the condition.
Syntax
bool any(bool test(E element));
Parameter
- Element represents each item in the list.
Return type
- Bool
Code
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');}}