Timer創(chuàng)建循環(huán)執(zhí)行 與取消
_startTimer() {
/*創(chuàng)建循環(huán)*/
_timer = new Timer.periodic(new Duration(seconds: 2), (timer) {
setState(() {
_randomColor();
});
});
}
_cancelTimer() {
_timer?.cancel();
}