countWords property

int get countWords

Returns the word count in the given String.

The pattern is based on spaces.

Example

String foo = 'Hello dear friend how you doing ?';
int count = foo.countWords; // returns 6 words.

Implementation

int get countWords => getWords.length;