paragraph method

String paragraph(
  1. int length
)

Implementation

String paragraph(int length) {
  var wordsCount = 0;
  final sentenceList = <String>[];
  var n = 0;
  while (wordsCount < length) {
    n++;
    if (n > 100) {
      break;
    }
    final count = math.min(length,
        math.max(10, math.min(3, random.nextInt(length - wordsCount))));
    sentenceList.add(sentence(count));
    wordsCount += count;
  }
  return sentenceList.join(' ');
}