countWord property

int get countWord

Counts the number of words in the string.

Words are considered to be separated by whitespace (spaces, tabs, line breaks).

Implementation

int get countWord =>
    trim().isEmpty ? 0 : RegExp(r'\S+').allMatches(this).length;