random method

T random([
  1. Random? random
])

Returns a random element from this collection.

@throws NoSuchElementException if this collection is empty.

Implementation

T random([math.Random? random]) {
  final r = random ?? math.Random();
  return elementAt(r.nextInt(size));
}