usePeriodicTimer method
Retrieves or creates a periodic Timer.
key
: A unique string key to identify the periodic Timer.
callback
: The function to execute on each timer tick.
duration
: The interval between timer ticks.
Returns a Timer that fires periodically, associated with the given key.
Implementation
Timer usePeriodicTimer({
required String key,
required void Function(Timer) callback,
required Duration duration,
}) {
return _getOrCreate(
key: key,
create: () => Timer.periodic(duration, callback),
disposeHandler: (timer) async => timer.cancel());
}