getNextMonth static method

List<String> getNextMonth(
  1. DateTime date
)

获取下月

Implementation

static List<String> getNextMonth(DateTime date) {
  // 下月第一天
  final nextMonthStart = DateTime(date.year, date.month + 1, 1);
  // 下月最后一天 = 下下月第一天 - 1 天
  final nextMonthEnd = DateTime(
    nextMonthStart.year,
    nextMonthStart.month + 1,
    1,
  ).subtract(Duration(days: 1));
  return [
    DateFormat('yyyy-MM-dd').format(nextMonthStart),
    DateFormat('yyyy-MM-dd').format(nextMonthEnd),
  ];
}