tick static method

Stream<Event> tick(
  1. Duration interval
)

Implementation

static Stream<Event> tick(Duration interval) {
  var i = 0;
  final controller = StreamController<Event>();
  Timer? timer;
  controller.onListen = () {
    timer = Timer.periodic(interval, (_) {
      controller.add(TickEvent(++i));
    });
  };
  controller.onCancel = () {
    timer?.cancel();
  };
  return controller.stream;
}