wordCount method

int wordCount()

Counts the number of words in a string.

Implementation

int wordCount() {
  return trim().isEmpty ? 0 : trim().split(RegExp(r'\s+')).length;
}