equals method Null safety

bool equals(
  1. List<E> other,
  2. [Equality<E> equality = const DefaultEquality()]
)

Whether other has the same elements as this list.

Returns true iff other has the same length as this list, and the elements of this list and other at the same indices are equal according to equality, which defaults to using ==.

Implementation

bool equals(List<E> other, [Equality<E> equality = const DefaultEquality()]) {
  if (length != other.length) return false;
  for (var i = 0; i < length; i++) {
    if (!equality.equals(this[i], other[i])) return false;
  }
  return true;
}