WordPair.random constructor

WordPair.random({
  1. int maxSyllables = maxSyllablesDefault,
  2. int top = topDefault,
  3. bool safeOnly = safeOnlyDefault,
  4. Random? random,
})

Creates a single WordPair randomly. Takes the same parameters as generateWordPairs.

If you need more than one word pair, this constructor will be inefficient. Get an iterable of random word pairs instead by calling generateWordPairs.

Implementation

factory WordPair.random(
    {int maxSyllables = maxSyllablesDefault,
    int top = topDefault,
    bool safeOnly = safeOnlyDefault,
    Random? random}) {
  random ??= _random;
  final pairsIterable = generateWordPairs(
      maxSyllables: maxSyllables,
      top: top,
      safeOnly: safeOnly,
      random: random);
  return pairsIterable.first;
}