same method

  1. @override
bool same(
  1. IList<T>? other
)
override

Will return true if the lists internals are the same instances (comparing by identity). This will be fast even for very large lists, since it doesn't compare each item.

May can also return true under some other situations where it's very cheap to determine that the lists are equal even if the lists internals are NOT the same.

Note: This is not the same as identical(list1, list2) since it doesn't compare the lists themselves, but their internal state. Comparing the internal state is better, because it will return true more often.

Implementation

@override
bool same(IList<T>? other) =>
    (other != null) &&
    (((other is IListConst) && identical(_list, (other as IListConst)._list)) ||
        (((other is IListEmpty) && _list.isEmpty))) &&
    (config == other.config);