asMap method

IMap<int, T> asMap()

Returns an IMap 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.

final IList<String> words = ['hel', 'lo', 'there'].lock;
final IMap<int, String> imap = words.asMap();
print(imap[0] + imap[1]); // Prints 'hello';
imap.keys.toList(); // [0, 1, 2, 3]

Implementation

IMap<int, T> asMap() => IMap<int, T>(UnmodifiableListFromIList(this).asMap());