pickSome<T> static method
Returns a random subset of the given values with a random size between min and max (inclusive).
Implementation
static List<T> pickSome<T>(List<T> values, {int? min, int? max}) {
if (values.isEmpty) {
throw ArgumentError('List cannot be empty');
}
final rand = math.Random();
int lower = min ?? 0;
int upper = max ?? values.length;
if (lower < 0) lower = 0;
if (upper > values.length) upper = values.length;
if (lower > upper) throw ArgumentError('min must be <= max');
int count = lower + rand.nextInt(upper - lower + 1);
final list = List<T>.from(values);
list.shuffle(rand);
return list.take(count).toList();
}