sublist method Null safety
override
Returns a new collection of the same type as the current collection
containing the elements between start
and end
.
If end
is omitted, it defaults to the length of this collection.
The start
and end
positions must satisfy the relations
0 ≤ start
≤ end
≤ length.
If end
is equal to start
, then the returned list is empty.
Implementation
@override
GpsPointsCollection<T> sublist(int start, [int? end]) {
end = RangeError.checkValidRange(start, end, length, 'start', 'end',
'incorrect parameters for sublist() call');
final result = newEmpty() as GpsPointsCollection<T>;
result.addAllStartingAt(this, start, end - start);
return result;
}