compareLists<R> method

  1. @protected
bool compareLists<R>(
  1. List<R>? list1,
  2. List<R>? list2
)

Determines whether list1 and list2 are equal.

Implementation

@protected
bool compareLists<R>(List<R>? list1, List<R>? list2) {
  if (identical(list1, list2)) return true;
  if (list1 == null || list2 == null) return false;
  final int length = list1.length;
  if (length != list2.length) return false;

  for (int i = 0; i < length; i++) {
    final dynamic unit1 = list1[i];
    final dynamic unit2 = list2[i];

    if (unit1 is Iterable || unit1 is Map) {
      if (!_equality.equals(unit1, unit2)) return false;
    } else if (unit1?.runtimeType != unit2?.runtimeType) {
      return false;
    } else if (unit1 != unit2) {
      return false;
    }
  }
  return true;
}