slidingWindow method
Sliding windows of size windowSize. Each window is a list of windowSize elements.
windowSize must be positive. Fewer than windowSize elements at the end are skipped.
Implementation
@useResult
Iterable<List<T>> slidingWindow(int windowSize) {
if (windowSize < 1) throw ArgumentError(_kErrWindowSizePositive, _kParamWindowSize);
final List<T> list = _thisAsListOrToList();
if (list.length < windowSize) return <List<T>>[];
return Iterable<List<T>>.generate(
list.length - windowSize + 1,
(int i) => list.sublist(i, i + windowSize),
);
}