getList<T> static method
Generates a list of random values from the provided list.
Parameters:
data
: The list of values.size
: The size of the generated list.min
: The minimum index to use for selecting a value. Default is 0.seed
: Seed for the random number generator. Default is null.
Example:
List<String> options = ['A', 'B', 'C', 'D'];
List<String> randomList = RandomProvider.getList(data: options, size: 3, min: 1, seed: 42);
// Result: List of 3 random values from the list ['B', 'C', 'D'].
Implementation
static List<T> getList<T>({
required List<T> data,
required int size,
int min = 0,
int? seed,
}) {
final List<T> list = [];
for (int i = 0; i < size; ++i) {
list.add(getValue(data: data, max: size, min: min, seed: seed) as T);
}
return list;
}