wordCount property

int get wordCount

Returns the number of words in this string.

Implementation

int get wordCount {
  if (isEmpty) return 0;
  return trim().split(RegExp(r'\s+')).where((w) => w.isNotEmpty).length;
}