add method

IList<T> add(
  1. T item
)

Return a new list with item added to the end of the current list, (thus extending the length by one).

Implementation

IList<T> add(T item) {
  var result = IList<T>._unsafe(_l.add(item), config: config);

  // A list created with `add` has a larger counter than its source list.
  // This improves the order in which lists are flushed.
  // If the outer list is used, it will be flushed before the source list.
  // If the source list is not used directly, it will not flush
  // unnecessarily, and also may be garbage collected.
  result._counter = _counter;
  result._count();

  return result;
}