words static method

String words(
  1. int min, [
  2. int? max
])

Generates a random text that consists of random number of random words separated by spaces.

  • min (optional) a minimum number of words.
  • max a maximum number of words. Returns a random text.

Implementation

/// - [min]   (optional) a minimum number of words.
/// - [max]   a maximum number of words.
/// Returns     a random text.

static String words(int min, [int? max]) {
  var result = '';

  var count = RandomInteger.nextInteger(min, max ?? min);
  for (var i = 0; i < count; i++) {
    if (i > 0) result += ' ';
    result += RandomString.pick(RandomText._allWords);
  }

  return result;
}