periodic method

Timer periodic(
  1. Duration duration,
  2. dynamic fn(
    1. Timer
    ), {
  3. Symbol? uniqueId,
})

Creates a periodic Timer.periodic that gets cancelled within dispose.

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 periodic(Duration duration, Function(Timer) fn, {Symbol? uniqueId}) {
  final tm = Timer.periodic(duration, (t) => fn(t));

  return _timer(tm, uniqueId: uniqueId);
}