startTest method

void startTest()

Implementation

void startTest() async {
  setState(() {
    activityStatus = ActivityStatus.Test;
  });
  widget.eventLogger.instructionEnded();
  widget.eventLogger.testStarted();
  for (int i = 3; i > 0; i--) {
    if (mounted) {
      setState(() {
        countdown = i.toString();
      });
    }
    await Future<dynamic>.delayed(const Duration(seconds: 1));
  }
  if (mounted) {
    //remove countdown text
    setState(() {
      counting = false;
    });
  }
  timer = Timer(Duration(seconds: widget.activity.lengthOfTest), () {
    //when time is up, change window and set result
    widget.eventLogger.testEnded();
    widget.onResultChange({'Total taps': taps});
    if (widget.activity.includeResults) {
      widget.eventLogger.resultsShown();
    }
    if (mounted) {
      setState(() {
        activityStatus = ActivityStatus.Result;
      });
    }
  });
}