limit method
Extract only the elements from start
to end
of Iterable.
Iterableをstart
からend
までの要素のみを抽出します。
final colors = <String>["red", "green", "blue", "orange", "pink"];
print(colors.limit(1, 3)); // [green, blue]
Implementation
List<T> limit(int start, int end) {
if (this is List) {
return (this as List).sublist(start, min(length, end)).cast<T>();
} else {
return toList().sublist(start, min(length, end));
}
}