Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Feb 23, 2024
Contribute to Docs

The Map object is a key/value pair. The values and keys in a map may be of any type. A Map is a dynamic collection that can grow and shrink at runtime.


The syntax to declare a map is:

var identifier = new Map()


Here is an example of how to use map in Dart:

void main() {
var details = {'Cat':'jeff','Color':'brown'};

The above code gives the following output:

{Cat: jeff, Color: brown}


Removes all the elements from a map.
Checks if a particular key is present in a Map object.
Returns an iterable collection containing all the keys in a map.
Retrieves the number of key-value pairs in a Map.
Inserts a key-value pair into a map if the key is not already present.

All contributors

Looking to contribute?

Learn Dart on Codecademy