updateThirdsCounter method

void updateThirdsCounter(
  1. int elapsedMs,
  2. int limitMs
)

Receives as arguments:

elapsedMs which is the total milliseconds elapsed since the test started

limitMs the duartion of the test in milliseconds.

With those two values it determines which third is the test in, gives value to thirdsCounter and calls notifyListeners

Implementation

void updateThirdsCounter(int elapsedMs, int limitMs){
  final newThird = (elapsedMs ~/ (limitMs / 3)).clamp(0,2);
  if (newThird != thirdsCounter) {
    thirdsCounter = newThird;
    notifyListeners();
  }
}