consecutivePairs method

List<(T, T)> consecutivePairs()

Adjacent pairs of elements; empty if length < 2. Audited: 2026-06-12 11:26 EDT

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]));
}