asMap method

  1. @override
Map<int, E> asMap()
override

An unmodifiable Map view of this list.

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.

var words = <String>['fee', 'fi', 'fo', 'fum'];
var map = words.asMap();  // {0: fee, 1: fi, 2: fo, 3: fum}
map.keys.toList(); // [0, 1, 2, 3]

Implementation

@override
Map<int, E> asMap() => elements.asMap();