lastDayOfMonth static method

DateTime lastDayOfMonth(
  1. DateTime month
)

The last day of a given month

Implementation

static DateTime lastDayOfMonth(DateTime month) {
  var beginningNextMonth = (month.month < 12)
      ? DateTime(month.year, month.month + 1, 1)
      : DateTime(month.year + 1, 1, 1);
  return beginningNextMonth.subtract(const Duration(days: 1));
}