moveToFirstWeekday static method

DateTime moveToFirstWeekday(
  1. DateTime date
)

Returns the first date of the week containing date.

Implementation

static DateTime moveToFirstWeekday(DateTime date) {
  if (date.weekday == DateTime.sunday) {
    return date;
  }

  return date.add(Duration(days: -date.weekday));
}