associateBy<K> method
Indexes elements by key, returning a Map<K, T>.
If multiple elements share a key, the last one wins.
users.associateBy((u) => u.id) // {1: User(1), 2: User(2)}
Implementation
Map<K, T> associateBy<K>(K Function(T) key) =>
{for (final e in this) key(e): e};