dart Creating a new Map


Example

Maps can be created in multiple ways.

Using the constructor, you can create a new map as follow:

var searchTerms = new Map();

Types for the key and value can also be defined using generics:

var nobleGases = new Map<int, String>();
var nobleGases = <int, String>{};

Maps can otherwise be created using the map literal:

var map = {
    "key1": "value1",
    "key2": "value2"
};