NormalizedCache.adopt constructor

NormalizedCache.adopt(
  1. Map<String, Map<String, Object?>> entities, {
  2. Normalization normalization = const Normalization(),
})

A cache hydrated from entities (the snapshot format) without copying them: the maps and lists are taken over and converted in place ({"__ref": key} maps become refs), so the caller must not touch them afterwards. For a persistence layer that just decoded them (jsonDecode output is mutable); Cache(initial:) copies.

Implementation

NormalizedCache.adopt(
  Map<String, Map<String, Object?>> entities, {
  this.normalization = const Normalization(),
}) {
  for (final e in entities.entries) {
    _entities[e.key] = _adopted(e.value);
  }
}