TimeRange constructor

TimeRange(
  1. DateTime start,
  2. DateTime stop,
  3. Duration step
)

Returns an iterable of integers from start inclusive to stop inclusive with step.

TimeRange(DateTime(2019, 1, 1), DateTime(2019, 1, 20), Duration(days: 1))

Implementation

factory TimeRange(DateTime start, DateTime stop, Duration step) {
  if (step.isNegative) {
    throw ArgumentError.value(step, 'step', 'Must be greater than 0');
  }
  if (stop.isBefore(start)) step = -step;
  return TimeRange._(start, stop, step);
}