text static method
Generates a random text, consisting of first names, last names, colors, stuffs, adjectives, verbs, and punctuation marks.
minLength
minimum amount of words to generate. Text will contain 'minSize' words if 'maxSize' is omitted.maxLength
(optional) maximum amount of words to generate. Returns a random text.
Implementation
/// - [minLength] minimum amount of words to generate. Text will contain 'minSize' words if 'maxSize' is omitted.
/// - [maxLength] (optional) maximum amount of words to generate.
/// Returns a random text.
static String text(int minLength, [int? maxLength]) {
maxLength = max(minLength, maxLength ?? minLength);
var size = RandomInteger.nextInteger(minLength, maxLength);
var result = '';
result += RandomString.pick(RandomText._allWords);
while (result.length < size) {
var next = RandomString.pick(RandomText._allWords);
if (RandomBoolean.chance(4, 6)) {
next = ' ' + next.toLowerCase();
} else if (RandomBoolean.chance(2, 5)) {
next = RandomString.pickChar(':,-') + next.toLowerCase();
} else if (RandomBoolean.chance(3, 5)) {
next = RandomString.pickChar(':,-') + ' ' + next.toLowerCase();
} else {
next = RandomString.pickChar('.!?') + ' ' + next;
}
result += next;
}
return result;
}