wordCount property
int
get
wordCount
Gets the count of words in a string
Example:
"Hello world".wordCount; // Returns 2
" Multiple spaces between ".wordCount; // Returns 3
Implementation
int get wordCount =>
trim().split(RegExp(r'\s+')).where((word) => word.isNotEmpty).length;