The map structure is one of the list types that allows us to keep more than one data. The most important features of Map:

  • It works as key – value.
  • unordered

We can think of this structure as a dictionary. A word has only one meaning. Here too, word=key, meaning=value corresponding to the word.

It is also important because we use the Map structure a lot when using a database. Below are examples of uses of the map structure.

main() {
  Map<String, int> map1 = {'zero': 0, 'one': 1, 'two': 2};
  print(map1);

  Map map2 = {'zero': 0, 'I': 'one', 10: 'X'};
  print(map2);

  var map3 = {'zero': 0, 'I': 'one', 10: 'X'};
  print(map3);
}

Output:

{zero: 0, one: 1, two: 2}
{zero: 0, I: one, 10: X}
{zero: 0, I: one, 10: X}

 

main() {
  List<String> letters = ['I', 'V', 'X'];
  List<int> numbers = [1, 5, 10];
  
  Map<String, int> map = Map.fromIterables(letters, numbers);
  print(map);
}

Output:

{I: 1, V: 5, X: 10}