getLastDayOfMonth static method

DateTime getLastDayOfMonth({
  1. DateTime? month,
})

Returns a date with the same month and year of the specified date, and the last day of that month.

If month is not specified, return the last day of the current month.

Implementation

static DateTime getLastDayOfMonth({DateTime? month}) {
  DateTime firstDayOfNextMonth = getFirstDayOfNextMonth(month: month);
  return firstDayOfNextMonth.subtract(const Duration(days: 1)).getDateOnly();
}