isLeapYear property

bool get isLeapYear

Checks if the year of this date is a leap year.

Example:

print(DateTime(2024, 1, 1).isLeapYear); // true

Implementation

bool get isLeapYear {
  final y = year;
  return (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0);
}