getFirstDayOfWeekForWeek method

DateTime getFirstDayOfWeekForWeek(
  1. int weekIndex,
  2. int year,
  3. int month
)

Implementation

DateTime getFirstDayOfWeekForWeek(
    int weekIndex, int year, int month) {
  DateTime firstDayOfMonth = DateTime(year, month, 1);
  while (firstDayOfMonth.weekday != 1) {
    firstDayOfMonth =
        firstDayOfMonth.subtract(const Duration(days: 1));
  }
  return firstDayOfMonth.add(Duration(days: 7 * weekIndex));
}