ListMap<K, V>.of constructor
Create a ListMap from the map
.
If sort
is true, it will sort with compare
, if provided,
or with compareObject if not provided. If sort
is false,
compare
will be ignored.
Implementation
ListMap.of(
Map<K, V> map, {
bool sort = false,
int Function(K a, K b)? compare,
}) : assert(compare == null || sort == true),
_map = HashMap.from(map),
_list = List.of(map.keys, growable: false) {
if (sort) _list.sort(compare ?? compareObject);
}