Member-only story
Mastering Dart Collections
A complete list of collections to skyrocket your app performance

Collections are a set of interfaces and classes that implement highly optimised data structures. They reduce the programming effort and improve the performance of the code if chosen carefully.
In this article, you will see the strengths and weaknesses of all the collections to enable you to choose the perfect fit for your use case.
Choosing the right collection solves 90% of the problem — managing it is the remaining part and it comes naturally after selecting the right one.
Before jumping into the more complex collections available, let’s have a look at the most common collection types in Dart.
Common Collection Types
The main collection types in Dart are:
- List
- Set
- Map
Lists are 0-indexed collections of objects with a length.
In other programming languages, they are called arrays.
Lists are Iterable
and the iteration occurs in the index order. If the length of the list is changed during an iteration, a ConcurrentModificationError
is thrown.
Sets are collections of objects in which every object can only occur once.
Two objects are considered indistinguishable, hence can occur only once, if they are equal with regard to the Object.==
operator.
Sets are Iterable
and the order of iteration depends on the specific Set implementations.
Maps are collections of key/value pairs, from which you retrieve a value using its associated key.
Every key in the map is unique.
Maps and the keys and values are Iterable
and the order of iteration depends on the specific Map implementations.
Collection Literals
Collection literals are a syntactic expression that evaluates to an aggregate collection type.
In Dart, collection literals are preferred over unnamed constructor instantiation of collections. (see relevant Effective Dart tip)