stride method Null safety

Iterable<E> stride(
  1. int stepSize,
  2. [int startIndex = 0]
)

Returns an Iterable<E> which iterates this using a custom stepSize and starting from startIndex.

  • If startIndex is a valid list index then the first element of the iterable will be: this.elementAt(startIndex).
  • The parameter stepSize must not be zero.

Implementation

Iterable<E> stride(int stepSize, [int startIndex = 0]) {
  if (stepSize == 0) {
    _throwError<E>();
  }
  return stepSize > 0
      ? _StrideIterable<E>(this, stepSize, startIndex)
      : _ReverseStrideIterable(this, stepSize, startIndex);
}