calculateReadingTime method

int calculateReadingTime()

Estimates the reading time of the text in minutes.

Assumes an average reading speed of 225 words per minute.

Example:

'This is a sample paragraph...'.calculateReadingTime(); // 1

Implementation

int calculateReadingTime() {
  final int wordCount = split(RegExp(r'\s+')).length;
  final double readingTime = wordCount / 225;
  return readingTime.ceil();
}