firstDayOfWeek static method

DateTime firstDayOfWeek({
  1. DateTime? date,
})

指定日期所在周的周一

Implementation

static DateTime firstDayOfWeek({DateTime? date}) {
  if (date == null) date = DateTime.now();
  if (date.weekday == 1) return date;
  return date.add(Duration(days: -(date.weekday - 1)));
}