isLeapYear function

bool isLeapYear(
  1. DateTime date
)

Return true if this is a leap year. Rely on DateTime to do the underlying calculation, even though it doesn't expose the test to us.

Implementation

bool isLeapYear(DateTime date) {
  var feb29 = DateTime(date.year, 2, 29);
  return feb29.month == 2;
}