calculateDateRange method

Map<String, bool> calculateDateRange (
  1. dynamic mode
)

Implementation

Map<String, bool> calculateDateRange(mode) {
  if (doesDateRangeExists) {
    DateTime _nextRowStartingDate;
    DateTime weekStartingDate, weekEndingDate;
    if (mode != null) {
      _nextRowStartingDate = mode == "PREV" ? rowStartingDate.subtract(Duration(days: 7)) : rowStartingDate.add(Duration(days: 7));
    } else {
      _nextRowStartingDate = rowStartingDate;
    }
    weekStartingDate = getDateOnly(_nextRowStartingDate);
    weekEndingDate = getDateOnly(_nextRowStartingDate.add(Duration(days: 6)));
    bool isStartingWeekOnRange = isDateAfter(widget.startDate, weekStartingDate);
    bool isEndingWeekOnRange = isDateBefore(widget.endDate, weekEndingDate);
    return {"isEndingWeekOnRange": isEndingWeekOnRange, "isStartingWeekOnRange": isStartingWeekOnRange};
  } else {
    return {"isEndingWeekOnRange": false, "isStartingWeekOnRange": false};
  }
}