roundToLastDayOfWeek static method

DateTime roundToLastDayOfWeek(
  1. DateTime date
)

Rounds the given DateTime to the last day of the week (Sunday).

Implementation

static DateTime roundToLastDayOfWeek(DateTime date) {
  final dayOfWeek = date.weekday;
  final daysToAdd = 7 - dayOfWeek;
  return date.add(Duration(days: daysToAdd));
}