paragraph function

TValueGenerator paragraph({
  1. required Random random,
  2. int sentences = 3,
})

Returns a generator that produces a paragraph of sentences sentences on each call.

Each sentence contains 8 lowercase lorem words. Sentences are joined by '. ' and the paragraph ends with '.'.

Throws ArgumentError if sentences is less than 1.

Implementation

TValueGenerator paragraph({
  required Random random,
  int sentences = 3,
}) {
  _requirePositive(sentences, 'sentences');
  return () {
    final parts = List.generate(
      sentences,
      (_) => _generateWords(random, 8),
    );
    return '${parts.join('. ')}.';
  };
}