tick method
Decrements the remaining duration by the specified delta amount.
If the timer is not running or duration is already zero, this method has no effect. If the decrement causes the remaining time to fall at or below zero, the timer stops running, clamps to zero, and invokes onFinished.
| Parameter | Type | Description |
|---|---|---|
delta |
Duration | The time step duration to subtract. |
Implementation
void tick(Duration delta) {
if (!running) return;
if (duration > Duration.zero) {
duration -= delta;
if (duration <= Duration.zero) {
duration = Duration.zero;
running = false;
if (onFinished != null) {
onFinished!();
}
}
}
}