lastDayOfMonth method

DateTime lastDayOfMonth (DateTime month)

Returns a new DateTime in the last day of the given month

Implementation

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