repeat method

void repeat(
  1. void callback(), {
  2. int times = 1,
})

🔁 Repeats a function after a delay

Example: Duration(seconds: 1).repeat(() => print('tick'));

Implementation

void repeat(void Function() callback, {int times = 1}) {
  for (var i = 0; i < times; i++) {
    Future.delayed(this * i, callback);
  }
}