startOfWeek property
DateTime
get
startOfWeek
Get the start of the week (Monday)
Example:
final date = DateTime(2023, 12, 25); // Wednesday
print(date.startOfWeek); // Monday of that week at 00:00:00
Implementation
DateTime get startOfWeek {
final daysFromMonday = weekday - 1;
return subtract(Duration(days: daysFromMonday)).startOfDay;
}