ListMap<K, V>.fromIterables constructor
ListMap<K, V>.fromIterables (})
Creates a ListMap from the provided keys
and values
.
If a key is repeated, the last occurrence overwrites the previous value.
If sort
is true
, it will be sorted with compare
, if provided,
or with compareObject if not provided. If sort
is false
,
compare
will be ignored.
The iterables keys
and values
must have the same number of items,
otherwise it throws a StateError.
Implementation
factory ListMap.fromIterables(
Iterable<K> keys,
Iterable<V> values, {
bool sort = false,
int Function(K a, K b)? compare,
}) {
Iterable<MapEntry<K, V>> combined =
combineIterables(keys, values, (K key, V value) => MapEntry(key, value));
return ListMap.fromEntries(combined, sort: sort, compare: compare);
}