rangeDouble function

List<double> rangeDouble(
  1. double start,
  2. double end,
  3. double step
)

Returns doubles from start (inclusive) toward end (exclusive) in increments of step. A negative step counts down; the result is empty when the range cannot advance toward end.

Example:

rangeDouble(0, 1, 0.5); // [0.0, 0.5]

Implementation

List<double> rangeDouble(double start, double end, double step) {
  final List<double> out = <double>[];
  for (double x = start; step > 0 ? x < end : x > end; x += step) {
    out.add(x);
  }
  return out;
}