getRandom method

T? getRandom([
  1. int? seed
])

Get a random element from List.

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

Listからランダムに要素を取得します。

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

Implementation

T? getRandom([int? seed]) {
  if (isEmpty) {
    return null;
  }
  final index = Random(seed).nextInt(length);
  return this[index];
}