timer method

Timer timer({
  1. required CAsyncTask task,
  2. required int interval,
})

Kicks off a timer to schedule tasks on the thread for which it is created calling the task on the interval specified in milliseconds.

Implementation

Timer timer({
  required CAsyncTask task,
  required int interval,
}) {
  assert(interval > 0, "interval specified must be greater than 0.");
  return Timer.periodic(
    Duration(milliseconds: interval),
    (timer) {
      task();
    },
  );
}