TimerComponent constructor
TimerComponent({
- required double period,
- bool repeat = false,
- bool autoStart = true,
- bool removeOnFinish = false,
- VoidCallback? onTick,
- bool tickWhenLoaded = false,
- int? tickCount,
- ComponentKey? key,
Creates a TimerComponent
period The period of time in seconds that the tick will be called
repeat When true, this will continue running after period is reached
autoStart When true, will start upon instantiation (default is true)
onTick When provided, will be called every time period is reached.
It can be changed later through Timer.onTick on timer.
tickWhenLoaded When true, will call onTick when the component is
first loaded (default is false).
tickCount The number of time the timer will tick before stopping.
This is is only used when repeat is true. If null,
the timer will run indefinitely.
Implementation
TimerComponent({
required double period,
bool repeat = false,
bool autoStart = true,
this.removeOnFinish = false,
VoidCallback? onTick,
this.tickWhenLoaded = false,
int? tickCount,
super.key,
}) {
timer = Timer(
period: period,
repeat: repeat,
onTick: onTick,
autoStart: autoStart,
tickCount: tickCount,
);
}