Future repeat(int times, dynamic action())

Source

static Future repeat(int times, action()) async {
  for (var i = 1; i <= times; i++) {
    await action();
  }
}