shuffleTo method

List<T> shuffleTo([
  1. Random? random
])

Randomly sort this list.

If random is specified, a random value is obtained according to the seed.

このリストをランダムに並べ替えます。

randomを指定するとシードに応じたランダム値を取得します。

final numbers = <int>[1, 2, 3, 4, 5];
final shuffled = numbers.shuffleTo();
print(numbers); // [1, 3, 4, 5, 2] OR some other random result.

Implementation

List<T> shuffleTo([Random? random]) {
  final shuffled = List<T>.from(this);
  shuffled.shuffle(random);
  return shuffled;
}