asMap method

Map<int, E> asMap()

Returns an unmodifiable Map view of this.

The map uses the indices of this list as keys and the corresponding objects as values. The Map.keys Iterable iterates the indices of this list in numerical order.

List<String> words = ['fee', 'fi', 'fo', 'fum'];
Map<int, String> map = words.asMap();
map[0] + map[1];   // 'feefi';
map.keys.toList(); // [0, 1, 2, 3]

Source

Map<int, E> asMap() {
  return new ListMapView<E>(this);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-collection/ListMixin/asMap.html