pickOne method

T pickOne([
  1. Random? random
])

Returns a random item. The randomness can be customized by setting random.

Example:

[1, 2, 3].pickOne(); // 2 (or 1 or 3)

Implementation

T pickOne([Random? random]) {
  final list = toList();
  list.shuffle(random);
  return list.first;
}