createText function

String createText({
  1. int numParagraphs = -1,
  2. int numSentences = -1,
})

Creates a text comprised of a number of paragraphs.

Each text is comprised of numParagraphs paragraphs, each of which contain numSentences sentences. If either parameter is omitted, a random number is generated.

Implementation

String createText({int numParagraphs = -1, int numSentences = -1}) {
  List<String> paragraphs = [];

  if (numParagraphs < 0) {
    numParagraphs = randomInt(3, 7);
  }
  for (var i = 0; i < numParagraphs; i++) {
    paragraphs.add(createParagraph(numSentences: numSentences));
  }

  return paragraphs.getRange(0, paragraphs.length).join("\n");
}