dartora

OrderedMap

OrderedMap<K, V> behaves like a normal Dart Map<K,V> but remembers the insertion order of keys. It stores key order in a MultiViewList<K> and values in a regular Map<K,V>. When iterating, keys and values are returned in the order they were first inserted unless explicitly removed or re‑ordered. This structure is useful when the order of items must stay stable across mutations and iteration.

Construction

OrderedMap({
  Map<K,V>? map,
  List<K>? keys,
})

The backing fields are:

Core map operations

OrderedMap implements all of Map<K,V>:

Iteration

Other features

Notes

OrderedMap is therefore ideal when you need a map whose iteration order stays predictable across modifications but you still want full Map behaviour.