wordCount method

int wordCount()

Get the number of words in a string.

Implementation

int wordCount() {
  if (this == null) {
    throw ArgumentError('string: $this');
  }
  if (this!.isEmpty) {
    return 0;
  }
  return this!.split(RegExp(r'\s+')).length;
}