totalDaysOfMonth static method

int totalDaysOfMonth({
  1. required int year,
  2. required int month,
})

Get total day of month

final totalDay = totalDaysOfMonth(year:2021, month:11);

print(totalDay) // 30

Implementation

static int totalDaysOfMonth({
  required int year,
  required int month,
}) {
  final result =
      (month < 12) ? DateTime(year, month + 1, 0) : DateTime(year + 1, 1, 0);
  return result.day;
}