slice method
Creates a slice of list
from start
up to end
exclusive
.
var list = [1, 2, 3, 4];
//It slices the list elements and hence modifies this list
list.slice(2); // list = [3, 4]
// Do not want to alter the list object ??
var list = [1, 2, 3, 4];
//It creates copy of list slices the list elements and creates new list
list.slice(2); // list = [3, 4]
Implementation
List<T?> slice(int start, [int? end]) {
return _privateSlice(start, end);
}