move<T> static method
Returns a new list with the element at from moved to position to.
Useful for reorderable lists. to is clamped to the valid range.
Arr.move(['a', 'b', 'c', 'd'], 0, 2); // ['b', 'c', 'a', 'd']
Implementation
static List<T> move<T>(Iterable<T> list, int from, int to) {
final source = list.toList();
if (from < 0 || from >= source.length) {
throw RangeError.index(from, source, 'from');
}
final target = to.clamp(0, source.length - 1);
final item = source.removeAt(from);
source.insert(target, item);
return source;
}