Flexible
Expanded
Timer
void onTick(Timer timer) {
setState(() {
totalSeconds -= 1;
});
}
void onStartPressed() {
timer = Timer.periodic(
const Duration(seconds: 1),
onTick,
);
}
cancel() : Timer ๊ฐ์ฒด์ cancel ๋ฉ์๋๋ฅผ ์ด์ฉํ์ฌ ํ์ด๋จธ ๋์์ ๋ฉ์ถ๋ค.void onPausePressed() {
timer.cancel();
setState(() {
isRunning = false;
});
}
String format(int seconds) {
var duration = Duration(seconds: seconds);
// 0:25:00.00 -> 25:00 ์ผ๋ก ๋ณํ ํ ๋ฆฌํด
return duration.toString().split(".").first.substring(2, 7);
}