consecutivePairs method

List<(T, T)> consecutivePairs()

Adjacent pairs of elements; empty if length < 2.

Implementation

List<(T, T)> consecutivePairs() {
  if (length < 2) return <(T, T)>[];
  return List<(T, T)>.generate(length - 1, (int i) => (this[i], this[i + 1]));
}