How to check if any of the elements in a list satisfy a given condition in Dart

1 Answer

0 votes
bool isEven(int n) => (n % 2 == 0);
 
void main() {
  var list = [4, 8, 3, 9, 10, 6, 17];
  
  var result = list.any(isEven);
  
  print(result);
}
 
 
 
 
/*
run:
 
true

*/

 



answered Oct 14, 2022 by avibootz

Related questions

1 answer 157 views
1 answer 151 views
1 answer 146 views
1 answer 172 views
1 answer 176 views
...