repeat function

void repeat(
  1. int times,
  2. void action(
    1. int
    )
)

Executes the given function action specified number of times.

A zero-based index of current iteration is passed as a parameter to action.

Implementation

@pragma('vm:prefer-inline')
@pragma('dart2js:tryInline')
void repeat(int times, void Function(int) action) {
  for (var i = 0; i < times; i++) {
    action(i);
  }
}