isInRange method

bool isInRange(
  1. Time start,
  2. Time end, {
  3. bool inclusiveStart = true,
  4. bool inclusiveEnd = true,
})

Checks if this time instance falls within the specified range.

By default, the range is inclusive of the start time and exclusive of the end time. Use inclusiveStart and inclusiveEnd to control boundary behavior.

Implementation

bool isInRange(Time start, Time end,
    {bool inclusiveStart = true, bool inclusiveEnd = true}) {
  bool afterStart = inclusiveStart
      ? !isBefore(start)
      : isAfter(start); // !isBefore includes same moment
  bool beforeEnd = inclusiveEnd
      ? !isAfter(end)
      : isBefore(end); // !isAfter includes same moment
  return afterStart && beforeEnd;
}