isEqualsMap<K, V> function

bool isEqualsMap<K, V>(
  1. Map<K, V>? m1,
  2. Map<K, V>? m2
)

Returns true if both maps, m1 and m2, have equals entries in the same order.

Implementation

bool isEqualsMap<K, V>(Map<K, V>? m1, Map<K, V>? m2) {
  if (identical(m1, m2)) return true;
  if (m1 == null) return false;
  if (m2 == null) return false;

  var length = m1.length;
  if (length != m2.length) return false;

  var entries1 = m1.entries;
  var entries2 = m2.entries;

  for (var i = 0; i < length; ++i) {
    var e1 = entries1.elementAt(i);
    var e2 = entries2.elementAt(i);

    if (e1 == e2) continue;

    if (e1.key != e2.key) return false;
    if (e1.value != e2.value) return false;
  }

  return true;
}