isValidRangeInMonth static method

bool isValidRangeInMonth({
  1. required DateTime date,
  2. required DateTime? start,
  3. required DateTime? end,
})

Returns whether date is in the range of the first day of start.month and the last day of end.month.

Implementation

static bool isValidRangeInMonth({
  required DateTime date,
  required DateTime? start,
  required DateTime? end,
}) {
  if (start != null && date.isBefore(DateTime(start.year, start.month, 1))) {
    return false;
  }

  if (end != null && date.isAfter(DateTime(end.year, end.month + 1, 0))) {
    return false;
  }

  return true;
}