timer method

Timer timer(
  1. Duration duration,
  2. 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 timer(Duration duration, Function() fn) {
  late _Timer ret;
  final tm = Timer(duration, () {
    ret._rem();
    fn();
  });
  ret = _timer(tm);

  return ret;
}