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

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've reached locked video content where the transcript will be shown as obfuscated text.

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 =;
var fullNames = {

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

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

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