isSameWeek method

bool isSameWeek(
  1. DateTime other
)

Whether this date is in the same week as other

Implementation

bool isSameWeek(DateTime other) {
  final thisMonday = subtract(Duration(days: weekday - 1));
  final otherMonday = other.subtract(Duration(days: other.weekday - 1));
  return DateTime(thisMonday.year, thisMonday.month, thisMonday.day) ==
      DateTime(otherMonday.year, otherMonday.month, otherMonday.day);
}