shuffle method

void shuffle ([Random random ])
override

Shuffles the elements of this list randomly.

Implementation

void shuffle([Random random]) {
  random ??= Random();
  int length = this.length;
  while (length > 1) {
    int pos = random.nextInt(length);
    length -= 1;
    var tmp = this[length];
    this[length] = this[pos];
    this[pos] = tmp;
  }
}