wordCount static method

int wordCount(
  1. String value
)

Returns the word count of value.

Implementation

static int wordCount(String value) {
  final trimmed = value.trim();
  if (trimmed.isEmpty) return 0;
  return trimmed.split(RegExp(r'\s+')).length;
}