random property

E random

Returns a random element from the list.

Throws a StateError if this is empty.

Implementation

E get random {
  if (isEmpty) {
    throw StateError('No element');
  }

  final rnd = Random();
  return this[rnd.nextInt(length)];
}