addUniqueRelation function

void addUniqueRelation(
  1. Map<String, List<Map<String, String>>> rm,
  2. String key,
  3. String value,
  4. String type,
)

Implementation

void addUniqueRelation(Map<String, List<Map<String, String>>> rm, String key, String value, String type) {
  var ok = rm.containsKey(key);
  if (!ok) {
    rm[key] = [{'outcome': value, 'type': type}];
  } else {
    bool exists = rm[key]!.any((relation) => relation['outcome'] == value && relation['type'] == type);
    if (!exists) {
      rm[key]!.add({'outcome': value, 'type': type});
    }
  }
}