previousWeek property
DateTime
get
previousWeek
Returns a DateTime instance representing the exact date of the previous week.
Example:
DateTime currentDate = DateTime(2024, 1, 15);
DateTime previousWeekDate = currentDate.previousWeek;
print(previousWeekDate); // Output: 2024-01-08 00:00:00
The previousWeek
extension calculates and returns a new DateTime instance
by subtracting seven days from the original date, representing the exact date of the previous week.
Implementation
DateTime get previousWeek => subtract(const Duration(days: 7));