copyWithRemoved method

List<T> copyWithRemoved(
  1. T item
)

Returns a copy with the first occurrence of item removed

Implementation

List<T> copyWithRemoved(T item) {
  final index = indexOf(item);
  if (index == -1) return List.of(this);
  return [...sublist(0, index), ...sublist(index + 1)];
}