listsEqual function

bool listsEqual(
  1. List? a,
  2. List? b
)

Checks Lists a and b for equality.

Returns true if a and b are both null, or they are the same length and every element of a is equal to the corresponding element at the same index in b.

Implementation

bool listsEqual(List? a, List? b) {
  if (a == b) return true;
  if (a == null || b == null) return false;
  if (a.length != b.length) return false;

  for (int i = 0; i < a.length; i++) {
    if (a[i] != b[i]) return false;
  }

  return true;
}