isYearCurrent method

bool isYearCurrent({
  1. DateTime? now,
})

Checks if the date is in the current calendar year.

Pass now to override the current time (useful for testing).

Returns: bool: True if the date is in the current year, false otherwise.

Implementation

// https://stackoverflow.com/questions/56427418/how-to-extract-only-the-time-from-datetime-now
bool isYearCurrent({DateTime? now}) => year == (now ?? DateTime.now()).year;