lorem function

String lorem ({int paragraphs: 3, int words: 100 })

Generates random text using latin words. Words are distributed evenly across the paragraphs.

Implementation

String lorem({int paragraphs = 3, int words = 100}) {
  if (paragraphs == null || paragraphs < 0) {
    throw new ArgumentError.value(paragraphs, "paragraphs");
  }
  if (words == null || words < 0) {
    throw new ArgumentError.value(words, "words");
  }

  if (paragraphs == 0 || words == 0) {
    return "";
  }

  if (paragraphs > words) {
    // Not possible, so we downside to match words
    paragraphs = words;
  }

  return _makeParagraphs(paragraphs, words);
}