numberOfWeeksInYear function

int numberOfWeeksInYear(
  1. int year
)

Gets the number of weeks in a year

Implementation

int numberOfWeeksInYear(int year) {
  final DateTime dec28 = DateTime(year, 12, 28);
  final int dayOfDec28 = int.parse(DateFormat('D').format(dec28));
  return ((dayOfDec28 - dec28.weekday + 10) / 7).floor();
}