removeNList method

void removeNList(
  1. List<T> items,
  2. int n
)

Remove first n occurrences of List items from the list. If n is negative, remove from end of list.

Implementation

void removeNList(List<T> items, int n) {
  if (n == 0) return;
  if (n > 0) {
    for (var i = 0; i < n; i++) {
      removeAllList(items);
    }
  } else {
    for (var i = 0; i < -n; i++) {
      removeAllList(items.reversed.toList());
    }
  }
}