startTimer method
void
startTimer(
- Key key,
- Duration duration,
- VoidCallback onFinish, {
- TimerController? controller,
- bool isPaused = false,
启动倒计时
Implementation
void startTimer(
Key key,
Duration duration,
VoidCallback onFinish, {
TimerController? controller,
bool isPaused = false,
}) {
final effectiveDuration = duration.isNegative ? Duration.zero : duration;
final notifier = _notifiers.putIfAbsent(
key,
() => AdvancedValueNotifier(effectiveDuration),
);
_entries[key]?._controller?._detach(_entries[key]!);
final entry = _TimerEntry.countdown(
key: key,
duration: effectiveDuration,
notifier: notifier,
onFinish: onFinish,
isPaused: isPaused,
onChanged: _scheduleNextTick,
);
_entries[key] = entry;
controller?._attach(entry);
_ensureLifecycleObserver();
entry.refresh();
_scheduleNextTick();
}