isListValuesIdentical function

bool isListValuesIdentical(
  1. List? l1,
  2. List? l2
)

Returns true if all list elements are identical.

Implementation

bool isListValuesIdentical(List? l1, List? l2) {
  if (l1 == null || l2 == null) return false;
  if (identical(l1, l2)) return true;

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

  if (length == 0) return true;

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

    if (!identical(v1, v2)) return false;
  }

  return true;
}