transformAttributes static method

Map<String, dynamic>? transformAttributes(
  1. Map<String, dynamic>? a,
  2. Map<String, dynamic>? b,
  3. bool priority
)

Transforms two attribute sets.

Implementation

static Map<String, dynamic>? transformAttributes(Map<String, dynamic>? a, Map<String, dynamic>? b, bool priority) {
  if (a == null) return b;
  if (b == null) return null;

  if (!priority) return b;

  final result = b.keys.fold<Map<String, dynamic>>({}, (attributes, key) {
    if (!a.containsKey(key)) attributes[key] = b[key];
    return attributes;
  });

  return result.isEmpty ? null : result;
}