lightRegulator method
void
lightRegulator()
Implementation
void lightRegulator() {
if (!first) {
lightTimer?.cancel();
}
//determines when light is changed, and starts timer when screen turns green. only called when light is red.
timer = _random.nextInt(widget.activity.switchInterval) + 1;
lightTimer = Timer(Duration(seconds: timer), () {
if (mounted && allowGreen) {
setState(() {
alert = ''; //"too quick alert set to nothing when light is green"
lightOn = true; //turn on green light
_sw.start(); //start stopwatch to track delay from green screen till tap.
});
}
});
first = false;
}