getNextWeek static method
获取下周
Implementation
static List<String> getNextWeek(DateTime date) {
// 当前周的周一
final thisWeekMonday = date.subtract(Duration(days: date.weekday - 1));
// 下周周一
final nextWeekMonday = thisWeekMonday.add(Duration(days: 7));
final nextWeekStart = DateTime(
nextWeekMonday.year,
nextWeekMonday.month,
nextWeekMonday.day,
);
final nextWeekSunday = nextWeekStart.add(Duration(days: 6));
return [
DateFormat('yyyy-MM-dd').format(nextWeekStart),
DateFormat('yyyy-MM-dd').format(nextWeekSunday),
];
}