Map in dart code example

Example 1: dart list to map

var map1 = Map.fromIterable(list, key: (e) => e.name, value: (e) => e.age);

Example 2: Map in dart

void main() { 
   var details = new Map(); 
   details['Usrname'] = 'admin'; 
   details['Password'] = 'admin@123'; 
   print(details); 
} 

// Output
// {Usrname: admin, Password: admin@123}

Example 3: flutter map

Widget build(BuildContext context) {
  return FlutterMap(
    options: MapOptions(
      center: LatLng(51.5, -0.09),
      zoom: 13.0,
    ),
    layers: [
      TileLayerOptions(
        urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
        subdomains: ['a', 'b', 'c']
      ),
      MarkerLayerOptions(
        markers: [
          Marker(
            width: 80.0,
            height: 80.0,
            point: LatLng(51.5, -0.09),
            builder: (ctx) =>
            Container(
              child: FlutterLogo(),
            ),
          ),
        ],
      ),
    ],
  );
}

Example 4: what is map in dart

void main() { 
   var details = new Map(); 
   details['Username'] = 'admin'; 
   details['Password'] = 'admin@123'; 
   print(details); 
}

Tags:

Misc Example