isBetween method
Checks if the current DateTime is between the specified start and end dates.
Args: start (DateTime): The start date of the range. end (DateTime): The end date of the range. inclusive (bool): If true, the start and end dates are included in the check. Defaults to true.
Returns: bool: True if the DateTime is between the start and end dates, false otherwise.
Implementation
bool isBetween(DateTime start, DateTime end, {bool inclusive = true}) {
if (inclusive) {
return (this == start || isAfter(start)) && (this == end || isBefore(end));
}
return isAfter(start) && isBefore(end);
}