ListMap<K, V>.unsafe constructor
Creates a ListMap backed by the provided map. No defensive copy will be made, so you have to make sure that the original map won't change after the ListMap is created, since this will render the ListMap in an invalid state.
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.
Note: The original map won't be sorted or modified in any way by simply
calling this constructor, even if sort
is true.
Implementation
ListMap.unsafe(
this._map, {
bool sort = false,
int Function(K a, K b)? compare,
}) : assert(compare == null || sort == true),
_list = List.of(_map.keys, growable: false) {
if (sort) _list.sort(compare ?? compareObject);
}