ListMap<K, V>.of constructor

ListMap<K, V>.of(
  1. Map<K, V> map, {
  2. bool sort = false,
  3. int compare(
    1. K a,
    2. K b
    )?,
})

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);
}