Filter a list

suggest change

Dart lets you filter a list with where. where returns a lazy Iterable; toList() collects it into a new list and does not change fruits.

var fruits = ['apples', 'oranges', 'bananas'];
var filtered = fruits.where((f) => f.startsWith('a')).toList(); // [apples]

You can combine conditions in the callback with && and ||.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents