insert method

  1. @override
void insert(
  1. int index,
  2. T element
)
override

Inserts element at position index in this slice. This increases the length of the underlying list and this slice by one and shifts all objects at or after the index towards the end. The underlying list must be growable. The index value must be non-negative and no greater than length. Note, the ranges of other slices on the underlying list will not change, therefore use with care as this may shift the underlying data in other slices.

Implementation

@override
void insert(int index, T element) {
  if (index > len()) {
    panic("'index' cannot be greater than the length of the slice.");
  }
  if (index < 0) {
    panic("'index' cannot be negative.");
  }
  _list.insert(_start + index, element);
  _end++;
}