choose<T> method
Chooses between the given values. Values further at the front of the list are considered less complex.
Implementation
Generator<T> choose<T>(List<T> values) {
assert(values.toSet().length == values.length,
'The list of values given to any.choice contains duplicate items.');
return simple(
generate: (random, size) => values[random.nextInt(
size.clamp(0, values.length),
)],
shrink: (option) sync* {
final index = values.indexOf(option);
if (index > 0) yield values[index - 1];
},
);
}