W3cubDocs

/Dart 2

sublist method

List<E> sublist (int start, [ int end ])

Returns a new list containing the objects from start inclusive to end exclusive.

List<String> colors = ['red', 'green', 'blue', 'orange', 'pink'];
colors.sublist(1, 3); // ['green', 'blue']

If end is omitted, the length of this is used.

colors.sublist(1);  // ['green', 'blue', 'orange', 'pink']

An error occurs if start is outside the range 0 .. length or if end is outside the range start .. length.

Implementation

List<E> sublist(int start, [int end]);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-core/List/sublist.html