random<T> static method

T random<T>(
  1. List<T> list
)

Returns a random element of list. Throws when list is empty.

Implementation

static T random<T>(List<T> list) {
  if (list.isEmpty) throw ArgumentError('list must not be empty');
  return list[_random.nextInt(list.length)];
}