mapIsEqual<K, V> static method
bool
mapIsEqual<
K, V>( - Map<K, V>? a,
- Map<K, V>? b
)
Implementation
static bool mapIsEqual<K, V>(Map<K, V>? a, Map<K, V>? b) {
// Handle null comparison
if (a == null) return b == null;
if (b == null || a.length != b.length) return false;
// Check if 'a' and 'b' are identical objects
if (identical(a, b)) return true;
// Compare the entries in 'a' and 'b'
for (final key in a.keys) {
if (!b.containsKey(key)) return false;
final valueA = a[key];
final valueB = b[key];
if (valueA is Map && valueB is Map) {
// Recursively compare maps
if (!mapIsEqual(valueA, valueB)) return false;
} else if (valueA is Iterable && valueB is Iterable) {
// Recursively compare iterables
if (!iterableIsEqual(valueA, valueB)) return false;
} else if (valueA != valueB) {
return false;
}
}
return true;
}