useTimer method
Retrieves or creates a one-time Timer.
key
: A unique string key to identify the Timer.
callback
: The function to execute when the timer fires.
duration
: The duration after which to fire the timer.
Returns a Timer associated with the given key.
Implementation
Timer useTimer({
required String key,
required void Function() callback,
required Duration duration,
}) {
return _getOrCreate(
key: key,
create: () => Timer(duration, callback),
disposeHandler: (timer) async => timer.cancel()
);
}