uniqueTimer method

Timer uniqueTimer(
  1. Symbol uniqueId,
  2. Duration duration,
  3. dynamic fn()
)

Creates a Timer that gets cancelled within dispose if not executed.

Set uniqueId to some Symbol to make this timer unique. This means that we will cancel the previous timer with same symbol before assigning a new one.

Implementation

Timer uniqueTimer(Symbol uniqueId, Duration duration, Function() fn) {
  late _Timer ret;
  final tm = Timer(duration, () {
    ret._rem();
    fn();
  });
  ret = _timer(tm, uniqueId: uniqueId);

  return ret;
}