Filter a list
suggest changeDart 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 ||.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents