wordCount property

int get wordCount

Returns the number of words in the string.

Implementation

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