isEqualsListDeep function

bool isEqualsListDeep(
  1. List? l1,
  2. List? l2, {
  3. ValueEquality? valueEquality,
})

Returns true if l1 and l2 are equals deeply (including values tree equality).

Implementation

bool isEqualsListDeep(List? l1, List? l2, {ValueEquality? valueEquality}) {
  if (identical(l1, l2)) return true;

  if (l1 == null || l2 == null) return false;

  var length = l1.length;
  if (length != l2.length) return false;

  for (var i = 0; i < length; ++i) {
    var v1 = l1[i];
    var v2 = l2[i];

    if (!isEqualsDeep(v1, v2, valueEquality: valueEquality)) return false;
  }

  return true;
}