Iterable.where(test) returns a lazy Iterable of every element for which test(e) returns true. The element type is unchanged and the original list is not modified; .toList() materializes the filtered view into a fresh List. This is the functional sibling of writing a for loop with an if body, and it composes with map, fold, and join for downstream pipeline stages.

Program

Play the program to keep only the scores at or above 80 and print them joined by commas.

where_filter.dart
void main() {
  var scores = [72, 88, 91, 65];
  var passing = scores.where((score) => score >= 80).toList();
  var labels = passing.join(',');
  print(labels);
}
where `list.where(test)` returns a lazy `Iterable` of every element where `test(e)` is `true`. The element type is unchanged and the source list is never modified.
toList `.toList()` materializes the lazy view into a concrete `List`, so downstream code (here `join`) can iterate a stable value.
filter vs transform `where` keeps a subset without rewriting any value; pair it with `map` when you also need to change each element along the way.