wordCount property
int
get
wordCount
Counts the number of words in this string
Example:
print('Hello world'.wordCount); // 2
print('Hello, world!'.wordCount); // 2
Implementation
int get wordCount {
if (isEmpty) return 0;
return trim().split(RegExp(r'\s+')).length;
}