Transforming With map, where, and toList
Reshape lists with iterable methods.
Reshaping Lists
Instead of looping by hand, Dart lets you transform lists with tidy iterable methods. You describe the result and Dart builds it. ✨
map Transforms Items
The map method runs a function on every item and produces a new sequence of the results, leaving the original untouched.
var nums = [1, 2, 3];
var doubled = nums.map((n) => n * 2);All lessons in this course
- Creating Lists and Indexing
- Adding, Removing, and Updating Items
- Searching and Sorting Lists
- Transforming With map, where, and toList