random method

T random({
  1. int? seed,
})

Returns a random element from the list. Throws StateError if the list is empty.

Implementation

T random({int? seed}) {
  if (isEmpty) throw StateError('Cannot pick from an empty list');
  return this[math.Random(seed).nextInt(length)];
}