isLeapYear static method

  1. @useResult
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. Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
static bool isLeapYear({required int year}) {
  final bool isDivisibleBy4 = year % DateConstants.leapYearModulo4 == 0;
  final bool isDivisibleBy100 = year % DateConstants.leapYearModulo100 == 0;
  final bool isDivisibleBy400 = year % DateConstants.leapYearModulo400 == 0;

  return isDivisibleBy4 && (!isDivisibleBy100 || isDivisibleBy400);
}