initializeMonth method

void initializeMonth(
  1. DateTime selectedMonth,
  2. List<MarkedDaysModel>? customList,
  3. bool isRange, {
  4. void onUserPicked(
    1. List<DateTime>
    )?,
})

Initializes the calendar with a specific selectedMonth, optional marked days customList, and a selection mode flag isRange. Also registers an optional onUserPicked callback.

Implementation

void initializeMonth(
  DateTime selectedMonth,
  List<MarkedDaysModel>? customList,
  bool isRange, {
  void Function(List<DateTime>)? onUserPicked,
}) {
  _selectedMonth = selectedMonth;
  final firstDay = DateTime(_selectedMonth.year, _selectedMonth.month, 1);
  _startOffset = (firstDay.weekday % 7);
  _totalDays = DateUtils.getDaysInMonth(
    _selectedMonth.year,
    _selectedMonth.month,
  );
  isRangeSelection = isRange;
  _onUserPickedCallback = onUserPicked;

  if (customList != null) {
    selectedDaysList = customList;
  }

  _userPicked = null;
  _rangeStart = null;
  _rangeEnd = null;
  notifyListeners();
}