moveToLastWeekday static method

DateTime moveToLastWeekday(
  1. DateTime date
)

Returns the last day of the week containing date.

Implementation

static DateTime moveToLastWeekday(DateTime date) {
  if (date.weekday == DateTime.saturday) {
    return date;
  }

  int moveCount =
      date.weekday == DateTime.sunday ? 6 : DateTime.saturday - date.weekday;

  return date.add(Duration(days: moveCount));
}