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>{};
  for (final key in (a.keys.toList()..addAll(b.keys))) {
    if (a[key] != b[key]) {
      attributes[key] = b.containsKey(key) ? b[key] : null;
    }
  }

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