sentence method

String sentence(
  1. int length
)

Implementation

String sentence(int length) {
  final wordList = <String>[];
  for (var i = 0; i < length; i++) {
    var w = word();
    if (i < length - 1 && random.nextInt(10) == 0) {
      w += ',';
    }
    wordList.add(w);
  }
  final text = '${wordList.join(' ')}.';
  return text[0].toUpperCase() + text.substring(1);
}