List? Set? Map? (dart programming)

Marva Athatillah
2 min readJul 15, 2022

Do you know what this title means? Wash your face, and let me explain.

In addition to strings, numbers, and booleans, Dart still has other data types that can store lots of data at once which in programming terms are known as collections. Collections are objects that can store a collection of other objects. Examples of collections on Dart include List, Set, and Map.

List

List as the name implies can accommodate a lot of data into one object. In everyday life we use lists to store shopping lists, phone numbers, etc. Likewise with Dart we can store various data types such as strings, numbers, and booleans. It’s also very easy to write. Just consider the following example:

List<int> numberList = [1, 2, 3, 4, 5];

Set

Next we will discuss the second type of collection, namely Set. A set is a collection that can only store unique values. This is useful when you don’t want the same or duplicate data to exist in a collection. We can declare a Set in the following ways:

var numberSet = {1, 4, 6};Set<int> anotherSet = new Set.from([1, 4, 6, 4, 1]);

Map

The third collection is Map, which is a collection that can store data in key-value format. Consider the following example:

var capital = {
'Jakarta': 'Indonesia',
'London': 'England',
'Tokyo': 'Japan'
};

I explain this is only a very basic explanation, just to know. For further explanation, please go to Dart’s official website to understand in more detail.

--

--