firstDayOfWeek static method
Returns the first day of the week containing date.
firstDay specifies which day starts the week (1 = Monday, 7 = Sunday).
Implementation
static DateTime firstDayOfWeek(DateTime date, {int firstDay = 1}) {
final diff = (date.weekday - firstDay + 7) % 7;
return dateOnly(date.subtract(Duration(days: diff)));
}