slice method
Returns a new list containing elements at indices between start
(inclusive) and end
(inclusive).
If end
is omitted, it is being set to lastIndex
.
Implementation
List<E> slice(int start, [int end = -1]) {
var list = this is List ? this as List<E> : toList();
if (start < 0) {
start = start + list.length;
}
if (end < 0) {
end = end + list.length;
}
RangeError.checkValidRange(start, end, list.length);
return list.sublist(start, end + 1);
}