randomItem method

T randomItem([
  1. Iterable<double> weights = const []
])

Returns a random item from this list.

weights can be used to select an item according to a weighted distribution.

Items with a higher weight will have a higher chance of being selected.

weights must be empty or have the same length as this list.

Implementation

T randomItem([Iterable<double> weights = const []]) =>
    randomChoice(this, weights);