Dart Chapter 5 of 15
Collections
Store and process groups of values with lists, sets and maps, then filter, transform and combine them.
Real programs deal with many values at once: a list of messages, a set of tags, a table of prices. Dart’s collections hold those values and come with powerful tools for searching and reshaping them.
Lessons in this chapter
- Dart Collections: List, Set and Map OverviewAn overview of collections in Dart. Compare List, Set and Map, learn collection literals and generics, and choose the right one.
- Lists in Dart: Create, Access, Add, Remove and SortComplete guide to List in Dart: creating lists, indexing, adding and removing items, searching, sorting, sublists and fixed-length lists.
- Sets in Dart: Unique Collections and Set OperationsLearn Set in Dart: storing unique values, fast lookups, and set operations such as union, intersection and difference.
- Maps in Dart: Key-Value Pairs ExplainedLearn Map in Dart: create key-value pairs, read, add, update and remove entries, loop over a map, and handle missing keys safely.
- MapEntry in Dart: Working with Map EntriesUse MapEntry and the entries property in Dart to sort, filter, transform and rebuild maps with fromEntries and map.
- Iterable in Dart: Lazy Sequences ExplainedUnderstand Iterable in Dart, the parent of List and Set. Learn lazy evaluation, take, skip, firstWhere and when to call toList.
- where, map, reduce and fold in Dart: Filter and Transform CollectionsFilter, transform and summarise collections in Dart with where, map, expand, reduce, fold, any and every, with practical examples.
- Spread Operator, Collection if and Collection for in DartBuild lists, sets and maps in Dart using the spread operator (...), null-aware spread, collection if and collection for.
- Queue in Dart: Adding and Removing from Both EndsLearn the Queue class from dart:collection. Add and remove items at both ends efficiently, and build FIFO queues and stacks.
- Collection Performance in Dart: Choosing the Fastest StructureUnderstand the speed of common List, Set and Map operations in Dart, and learn practical tips for writing faster collection code.