isLeapYear static method

bool isLeapYear({
  1. required int year,
})

Checks if the given year is a leap year.

Returns true if the year is a leap year, false otherwise.

Implementation

static bool isLeapYear({required int year}) =>
    // A year is a leap year if it is divisible by 4
    year % leapYearModulo4 == 0
    // A year is not a leap year if it is divisible by 100
    &&
    (year % leapYearModulo100 != 0
        // unless it is also divisible by 400
        ||
        year % leapYearModulo400 == 0);