phrase static method

String phrase(
  1. int minLength, [
  2. int? maxLength
])

Generates a random phrase which consists of few words separated by spaces. The first word is capitalized, others are not.

  • minLength (optional) minimum string length.
  • maxLength maximum string length. Returns a random phrase.

Implementation

/// - [minLength]     (optional) minimum string length.
/// - [maxLength]     maximum string length.
/// Returns a random phrase.

static String phrase(int minLength, [int? maxLength]) {
  maxLength = max(minLength, maxLength ?? minLength);
  var size = RandomInteger.nextInteger(minLength, maxLength);
  if (size <= 0) return '';

  var result = '';
  result += RandomString.pick(RandomText._allWords);
  while (result.length < size) {
    result += ' ' + RandomString.pick(RandomText._allWords).toLowerCase();
  }

  return result;
}