slice<T> function

List<T>? slice<T>(
  1. List<T> list,
  2. int start, [
  3. int? end
])

Creates a slice of list from start up to, but not including, end.

var list = [1, 2, 3, 4];

// Does not alters list object and returns a new sliced list object
var newSlicedList = slice(list, 2); // newSlicedList = [3, 4]

// Direclty slices the list and does not makes a new object.
var old_object_slicedList = list.slice(2); // [3, 4]

Implementation

List<T>? slice<T>(List<T> list, int start, [int? end]) {
  return list._privateSlice(start, end, false) as List<T>?;
}