randomize method
Randomly selects elements from multiple lists while ensuring uniqueness.
Parameters:
root: A list of lists containing possible values.length: The desired number of elements in the result.initial: An optional list of initial values (default is empty).converter: A function to modify selected items before adding them.
Example:
List<List<String>> root = [
['A', 'B', 'C'],
['D', 'E'],
['F', 'G', 'H']
];
List<String> result = root.randomize(length: 5);
// Possible output: ['B', 'D', 'F', 'C', 'E']
Implementation
List<T> randomize({
int? length,
List<T> initial = const [],
T Function(int index, T old)? converter,
}) {
return RandomProvider.randomize(
this,
length: length,
initial: initial,
converter: converter,
);
}