Maps in Dart and Flutter

Dart, Google Flutter, maps -

Maps in Dart and Flutter

Introduction

An object that maps keys to values. Both keys and values in a map may be of any type. A Map is a dynamic collection. In other words, Maps can grow and shrink at runtime.

Example

void main() {
  Map<String, String> stateNamesByStateCode =
  {"AL": "Alamaba",
   "AK": "Alaska",
   "AR": "Arkansas",
   "AZ": "Arizona"
  };
 
  stateNamesByStateCode["GA"] = "Georgia";
 
  for (String key in stateNamesByStateCode.keys){
            print(stateNamesByStateCode[key]);   
  }
 
  print("\nGet just one: ${stateNamesByStateCode["AK"]}");
}

Example Output

Alamaba
Alaska
Arkansas
Arizona
Georgia
 
Just one: Alaska