keyFieldsWithArgs function

SplayTreeMap<String, dynamic> keyFieldsWithArgs(
  1. Map<String, dynamic> keyFields,
  2. Map data
)

Implementation

SplayTreeMap<String, dynamic> keyFieldsWithArgs(
  Map<String, dynamic> keyFields,
  Map data,
) =>
    keyFields.entries.fold(
      SplayTreeMap(),
      (fields, entry) {
        if (entry.value is Map) {
          return fields
            ..[entry.key] =
                keyFieldsWithArgs(entry.value, data[entry.key] ?? {});
        } else if (entry.value == true) {
          if (!data.containsKey(entry.key)) throw MissingKeyFieldException();
          return fields..[entry.key] = data[entry.key];
        }
        return fields;
      },
    );