leapYear static method

  1. @useResult
bool leapYear(
  1. int year
)

Returns true if the year is a leap year.

Dates.leapYear(2020); // true
Dates.leapYear(2022); // false

Implementation

@useResult static bool leapYear(int year) => year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);