normalizeWith method Null safety

Map<String, List> normalizeWith(
  1. JsonSchema schema,
  2. Map<String, dynamic> json
)

Normalizes the given JSON object using the specified schema object.

Returns a map of normalized JSON objects, where each key corresponds to the name of an entity and the value is a list of normalized JSON objects for that entity.

Implementation

Map<String, List> normalizeWith(
  JsonSchema schema,
  Map<String, dynamic> json,
) {
  final result = <String, List>{};
  void accumulator(String name, dynamic key, dynamic entity) {
    result[name] ??= [];
    result[name]!.add(entity);
  }

  _normalize(json, schema, accumulator, _find);

  return result;
}