maxWords method
Implementation
String? maxWords(int maxWords) {
if (this == null) return null;
if (this!.isEmpty) return this;
final words = this!.split(' ');
if (words.length <= maxWords) {
return this;
} else {
final limitedWords = words.sublist(0, maxWords);
return limitedWords.join(' ');
}
}