pickSome method

List<T> pickSome(
  1. int count, [
  2. Random? random
])

Returns an List of count random items. The randomness can be customized by setting random.

Example:

[1, 2, 3].pickSome(2); // [1, 2] or [3, 2] and so on...

Implementation

List<T> pickSome(int count, [Random? random]) {
  ArgumentError.checkNotNull(count, 'count');
  final list = toList();
  list.shuffle(random);
  return list.take(min(count, length)).toList();
}