declare map flutter code example

Example 1: flutter create new map

Map<String, int> map1 = {'zero': 0, 'one': 1, 'two': 2};
Map map2 = {'zero': 0, 'I': 'one', 10: 'X'};
var map3 = {'zero': 0, 'I': 'one', 10: 'X'};

Example 2: 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(),
            ),
          ),
        ],
      ),
    ],
  );
}

Tags:

Dart Example