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 % 4 == 0
    // A year is not a leap year if it is divisible by 100
    &&
    (year % 100 != 0
        // unless it is also divisible by 400
        ||
        year % 400 == 0);