xxxxxxxxxx
DateTime date = DateTime.now();
int year = date.year.floor();
print(year); //prints only the year excluding the month and day
xxxxxxxxxx
int year = DateTime.now().year;
int month = DateTime.now().month;
DateTime thisMonth = DateTime(year,month,0);
DateTime nextMonth = DateTime(year,month+1,0);
int days = nextMonth.difference(thisMonth).inDays;
print("Days In This Month: $days");
xxxxxxxxxx
int daysInMonth(DateTime date) => DateTimeRange(
start: DateTime(date.year, date.month,1),
end: DateTime(date.year, date.month + 1))
.duration
.inDays;
print("Days in current month is ${daysInMonth(DateTime.now())}");