wordLimit method

String wordLimit(
  1. int wordCount
)

Get first N words

Implementation

String wordLimit(int wordCount) {
  List<String> sentence = this.split(" ");
  List<String> cropped = [];

  if (sentence.length > wordCount) {
    cropped.addAll(sentence.take(wordCount));
    cropped.add('...');

    return cropped.join(" ");
  }

  return this;
}