getIntersection method
- Period other
Returns a Period that is the intersection of this and other
.
If other
does not overlap with this, the returned Period will be
null
.
If other
overlaps with this, the returned Period will be the
intersection of the two Periods. Starting at the latest Period.start
and ending at the earliest Period.end.
Implementation
Period? getIntersection(Period other) {
if (doesNotOverlapWith(other)) return null;
return Period(
start: start.isAfter(other.start) ? start : other.start,
end: end.isBefore(other.end) ? end : other.end,
);
}