wordCount static method

int wordCount(
  1. String text
)

Word count for text

Implementation

static int wordCount(String text) {
  return text.trim().split(RegExp(r'\s+')).where((word) => word.isNotEmpty).length;
}