multi static method

DayPicker<List<DateTime>> multi({
  1. Key? key,
  2. required List<DateTime> selectedDates,
  3. required ValueChanged<List<DateTime>> onChanged,
  4. required DateTime firstDate,
  5. required DateTime lastDate,
  6. DatePickerLayoutSettings datePickerLayoutSettings = const DatePickerLayoutSettings(),
  7. DateTime? initiallyShowDate,
  8. DatePickerRangeStyles? datePickerStyles,
  9. DatePickerKeys? datePickerKeys,
  10. SelectableDayPredicate? selectableDayPredicate,
  11. EventDecorationBuilder? eventDecorationBuilder,
  12. ValueChanged<DateTime>? onMonthChanged,
})

Creates a day picker where many single days can be selected.

See also:

Implementation

static DayPicker<List<DateTime>> multi(
    {Key? key,
    required List<DateTime> selectedDates,
    required ValueChanged<List<DateTime>> onChanged,
    required DateTime firstDate,
    required DateTime lastDate,
    DatePickerLayoutSettings datePickerLayoutSettings =
        const DatePickerLayoutSettings(),
    DateTime? initiallyShowDate,
    DatePickerRangeStyles? datePickerStyles,
    DatePickerKeys? datePickerKeys,
    SelectableDayPredicate? selectableDayPredicate,
    EventDecorationBuilder? eventDecorationBuilder,
    ValueChanged<DateTime>? onMonthChanged}) {
  final startOfTheFirstDate = DatePickerUtils.startOfTheDay(firstDate);
  final endOfTheLastDate = DatePickerUtils.endOfTheDay(lastDate);
  final startOfTheInitiallyShowDate = initiallyShowDate == null
      ? null
      : DatePickerUtils.startOfTheDay(initiallyShowDate);
  final selectedDaysStarts =
      selectedDates.map(DatePickerUtils.startOfTheDay).toList();

  assert(!startOfTheFirstDate.isAfter(endOfTheLastDate));
  assert(!endOfTheLastDate.isBefore(startOfTheFirstDate));
  assert(startOfTheInitiallyShowDate == null ||
      !startOfTheInitiallyShowDate.isAfter(endOfTheLastDate));
  assert(startOfTheInitiallyShowDate == null ||
      !startOfTheInitiallyShowDate.isBefore(startOfTheFirstDate));

  final selection = DayPickerMultiSelection(selectedDaysStarts);
  final selectionLogic = DayMultiSelectable(
    selectedDaysStarts,
    startOfTheFirstDate,
    endOfTheLastDate,
    selectableDayPredicate: selectableDayPredicate,
  );

  return DayPicker<List<DateTime>>._(
    onChanged: onChanged,
    firstDate: startOfTheFirstDate,
    lastDate: endOfTheLastDate,
    initiallyShowDate: startOfTheInitiallyShowDate,
    selectionLogic: selectionLogic,
    selection: selection,
    eventDecorationBuilder: eventDecorationBuilder,
    onMonthChanged: onMonthChanged,
    selectableDayPredicate: selectableDayPredicate,
    datePickerKeys: datePickerKeys,
    datePickerStyles: datePickerStyles,
    datePickerLayoutSettings: datePickerLayoutSettings,
  );
}