Period constructor

Period({
  1. required DateTime start,
  2. required DateTime end,
})

Creates a period of time between two DateTimes.

Implementation

Period({
  required this.start,
  required this.end,
}) {
  if (start.isAfter(end)) {
    throw ArgumentError.value(
      end,
      'end',
      'End must be after or equals to start.',
    );
  }
  if (start.isUtc ^ end.isUtc) {
    throw ArgumentError.value(
      end,
      'end',
      'Start and end must be both UTC or both local.',
    );
  }
}