StreamMap<K, V>.fromIterables constructor
StreamMap<K, V>.fromIterables (
- Iterable<
K> keys, - Iterable<
V> values, { - OnUpdate<
Map< ? onUpdate,K, V> > - OnEvent<
CollectionEvent< ? onEvent,K, V> > - OnChange<
CollectionChangeEvent< ? onChange,K, V> >
Creates a StreamMap that wraps a Map instance associating the
given keys
to values
.
The created map is a LinkedHashMap.
A LinkedHashMap
requires the keys to implement compatible
operator==
and hashCode
, and it allows null as a key.
It iterates in key insertion order.
This constructor iterates over keys
and values
and maps each
element of keys
to the corresponding element of values
.
List<String> letters = ['b', 'c'];
List<String> words = ['bad', 'cat'];
Map<String, String> map = Map.fromIterables(letters, words);
map['b'] + map['c']; // badcat
If keys
contains the same object multiple times, the last occurrence
overwrites the previous value.
The two Iterables must have the same length.
Implementation
factory StreamMap.fromIterables(
Iterable<K> keys,
Iterable<V> values, {
OnUpdate<Map<K, V>>? onUpdate,
OnEvent<CollectionEvent<K, V>>? onEvent,
OnChange<CollectionChangeEvent<K, V>>? onChange,
}) {
return StreamMap<K, V>(
value: Map<K, V>.fromIterables(keys, values),
onUpdate: onUpdate,
onEvent: onEvent,
onChange: onChange,
);
}