range function

List<int> range({
  1. int start = 0,
  2. required int end,
  3. int step = 1,
})

Implementation

List<int> range({int start = 0, required int end, int step = 1}) {
  assert(step != 0);

  var result = <int>[];

  if (step > 0) {
    for (var i = start; i < end; i += step) {
      result.add(i);
    }
  } else {
    for (var i = start; i > end; i += step) {
      result.add(i);
    }
  }

  return result;
}