swapRemove method
Removes an element from the vector and returns it. The removed element is replaced by the last element of the vector.
Implementation
T swapRemove(int index) {
final removed = this[index];
this[index] = removeLast();
return removed;
}