CalendarDateRangePicker constructor

CalendarDateRangePicker({
  1. Key? key,
  2. DateTime? initialStartDate,
  3. DateTime? initialEndDate,
  4. required DateTime firstDate,
  5. required DateTime lastDate,
  6. DateTime? currentDate,
  7. required ValueChanged<DateTime>? onStartDateChanged,
  8. required ValueChanged<DateTime?>? onEndDateChanged,
})

Creates a scrollable calendar grid for picking date ranges.

Implementation

CalendarDateRangePicker({
  Key? key,
  DateTime? initialStartDate,
  DateTime? initialEndDate,
  required DateTime firstDate,
  required DateTime lastDate,
  DateTime? currentDate,
  required this.onStartDateChanged,
  required this.onEndDateChanged,
}) : initialStartDate = initialStartDate != null ? DateUtils.dateOnly(initialStartDate) : null,
     initialEndDate = initialEndDate != null ? DateUtils.dateOnly(initialEndDate) : null,
     assert(firstDate != null),
     assert(lastDate != null),
     firstDate = DateUtils.dateOnly(firstDate),
     lastDate = DateUtils.dateOnly(lastDate),
     currentDate = DateUtils.dateOnly(currentDate ?? DateTime.now()),
     super(key: key) {
  assert(
    this.initialStartDate == null || this.initialEndDate == null || !this.initialStartDate!.isAfter(initialEndDate!),
    'initialStartDate must be on or before initialEndDate.',
  );
  assert(
    !this.lastDate.isBefore(this.firstDate),
    'firstDate must be on or before lastDate.',
  );
}