diffAttributes static method

Map<String, dynamic>? diffAttributes(
  1. Map<String, dynamic>? a,
  2. Map<String, dynamic>? b
)

Returns diff between two attribute sets

Implementation

static Map<String, dynamic>? diffAttributes(Map<String, dynamic>? a, Map<String, dynamic>? b) {
  a ??= const {};
  b ??= const {};

  final attributes = <String, dynamic>{};
  var list = a.keys.toList();
  list.addAll(b.keys);
  for (var key in list) {
    if (a[key] != b[key]) {
      attributes[key] = b.containsKey(key) ? b[key] : null;
    }
  }

  return attributes.keys.isNotEmpty ? attributes : null;
}