lastDayOfMonth static method
Implementation
static DateTime lastDayOfMonth({int? month, int? year}) {
DateTime now = new DateTime.now();
int targetMonth = month == null ? now.month : month;
int targetYear = year == null ? now.year : year;
if(targetMonth == 12){
targetYear = targetYear + 1;
targetMonth = 1;
}
else{
targetMonth = targetMonth + 1;
}
DateTime lastDayOfMonth = new DateTime(targetYear, targetMonth, 0);
return lastDayOfMonth;
}