startTest method
void
startTest()
Implementation
void startTest() async {
await Future<dynamic>.delayed(const Duration(seconds: 1));
//periodic timer to update number on screen - starts in init currently.
timer = Timer.periodic(displayTime, (Timer t) {
//make sure window is mounted and that test is live before setting state.
if (activityStatus == ActivityStatus.Test && mounted) {
setState(() {
numGenerator();
sequenceChecker(widget.activity
.sequence); //check for sequence - could be for looped through multiple sequences if wanted, displayng current one.
});
} else {
t.cancel();
}
});
Timer(Duration(seconds: widget.activity.lengthOfTest), () {
//when time is up, change window and set result
if (mounted) {
widget.eventLogger.testEnded();
widget.onResultChange({
'Correct taps': goodTaps,
'incorrect taps': badTaps,
'passed sequences': seqPassed,
'Delay on correct taps': delaysList,
});
if (widget.activity.includeResults) {
widget.eventLogger.resultsShown();
setState(() {
activityStatus = ActivityStatus.Result;
});
}
}
});
}