getDays method

int getDays({
  1. int? year,
})

Returns the number of days in the month It takes the year as an optional parameter

If the month is february, it checks if it is a leap year or not. If year is null, it uses the current year as default.

Implementation

int getDays({int? year}) {
  if (month == 2) {
    final bool isLeap = isLeapYear(year ?? DateTime.now().year);
    if (isLeap) {
      return _days + 1;
    }
    return _days;
  }
  return _days;
}