Programming in Dart: Functions & Closures

Jun 21 2022 · Dart 2.16, Flutter, DartPad

Part 2: Learn Anonymous Functions & Closures

12. Map & Filter Collections

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 11. Use Anonymous Functions Next episode: 13. Challenge: Write an Anonymous Method

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Now that you have a good idea at how to work with anonymous functions, it’s time to build on that by working with a list. A list comes with two different functions called map and filter. We will start with the map function.

var names = [
    { 'firstName': 'Frank', 'lastName': 'Oz' },
    { 'firstName': 'Jim', 'lastName': 'Henson' },
    { 'firstName': 'Stan', 'lastName': 'Winston' }
];
var fullNames = 
var fullNames = names.map();
var fullNames = names.map((item) {

});
final firstName = item['firstName'];
final lastName = item['lastName'];
if (firstName != null && lastName != null) {

}
return '$firstName $lastName';
print(fullNames);
var muppetCreators = names.where((item) {

});
final lastName = item['lastName'];
if (lastName != null) {
    return (lastName == 'Oz' || lastName == 'Henson');
}
return false;
print(muppetCreators);