readTime method
Returns the average read time duration of the given String
.
The default calculation is based on 200 words per minute.
You can pass the wordsPerDuration
and duration
parameters for different read speeds.
Example
String foo = 'Hello dear friend how you doing ?';
int readTime = foo.readTime(); // returns 3 seconds.
Implementation
Duration readTime({int wordsPerDuration = 200, Duration duration = const Duration(minutes: 1)}) => isBlank || wordsPerDuration == 0 ? 0.seconds : (countWords / (wordsPerDuration * duration.inSeconds)).seconds;