lorem function Null safety

String lorem(
  1. {int paragraphs = 3,
  2. 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 < 0) {
    throw ArgumentError.value(paragraphs, "paragraphs");
  }
  if (words < 0) {
    throw 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);
}