insert method
insert method.
Implementation
void insert(int index, T item) {
throwIfDisposed('insert');
/// Stores the =.
final current = value;
/// if method.
if (index < 0 || index > current.length) {
return; // Bounds check
}
/// Stores the =.
final newList = List<T>.filled(current.length + 1, item);
// Copy elements before insertion point
/// for method.
for (int i = 0; i < index; i++) {
newList[i] = current[i];
}
newList[index] = item;
// Copy elements after insertion point
/// for method.
for (int i = index; i < current.length; i++) {
newList[i + 1] = current[i];
}
value = newList;
}