isEqualTo method

bool isEqualTo(
  1. List<T> other, {
  2. bool compare(
    1. T,
    2. T
    )?,
})

检查两个列表是否相同 >>>

Implementation

bool isEqualTo(List<T> other, {bool Function(T, T)? compare}) {
  if (this.length != other.length) {
    return false;
  }

  for (int i = 0; i < this.length; ++i) {
    if (compare == null) {
      if (this[i] != other[i]) {
        return false;
      }
    } else {
      if (!compare(this[i], other[i])) {
        return false;
      }
    }
  }

  return true;
}