asMap method Null safety
override
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(); // {0: fee, 1: fi, 2: fo, 3: fum}
map[0] + map[1]; // 'feefi';
map.keys.toList(); // [0, 1, 2, 3]
Implementation
Map<int, E> asMap() {
return ListMapView<E>(this);
}