swap method

void swap(
  1. Pair<T1, T2> other
)

Exchanges the contents of this pair with those of other.

Implementation

void swap(Pair<T1, T2> other) {
  final tempFirst = first;
  final tempSecond = second;
  first = other.first;
  second = other.second;
  other.first = tempFirst;
  other.second = tempSecond;
}