take method
Implementation
List<T> take(int n) {
if (this == null) return <T>[];
if (n <= 0) return [];
var list = <T>[];
if (this is Iterable) {
if (n >= this!.length) return this!.toList();
var count = 0;
var thisList = this!.toList();
for (var item in thisList) {
list.add(item);
if (++count == n) break;
}
}
return list;
}