compareLists function

bool compareLists(
  1. List array1,
  2. List array2
)

Compares two lists of dynamic elements for equality.

Implementation

bool compareLists(List<dynamic> array1, List<dynamic> array2) {
  // Check if lists have the same length.
  if (array1.length != array2.length) {
    return false;
  }

  // Iterate through elements and compare each pair.
  for (int i = 0; i < array1.length; i++) {
    if (array1[i] != array2[i]) {
      return false;
    }
  }

  // If all elements are equal, return true.
  return true;
}