DatePickerDialog constructor

DatePickerDialog({
  1. Key? key,
  2. Jalali? initialDate,
  3. required Jalali firstDate,
  4. required Jalali lastDate,
  5. Jalali? currentDate,
  6. PersianDatePickerEntryMode initialEntryMode = PersianDatePickerEntryMode.calendar,
  7. PersianSelectableDayPredicate? selectableDayPredicate,
  8. String? cancelText,
  9. String? confirmText,
  10. String? helpText,
  11. PersianDatePickerMode initialCalendarMode = PersianDatePickerMode.day,
  12. String? errorFormatText,
  13. String? errorInvalidText,
  14. String? fieldHintText,
  15. String? fieldLabelText,
  16. TextInputType? keyboardType,
  17. String? restorationId,
  18. ValueChanged<PersianDatePickerEntryMode>? onDatePickerModeChange,
  19. Icon? switchToInputEntryModeIcon,
  20. Icon? switchToCalendarEntryModeIcon,
})

A Material-style date picker dialog.

Implementation

DatePickerDialog({
  super.key,
  Jalali? initialDate,
  required Jalali firstDate,
  required Jalali lastDate,
  Jalali? currentDate,
  this.initialEntryMode = PersianDatePickerEntryMode.calendar,
  this.selectableDayPredicate,
  this.cancelText,
  this.confirmText,
  this.helpText,
  this.initialCalendarMode = PersianDatePickerMode.day,
  this.errorFormatText,
  this.errorInvalidText,
  this.fieldHintText,
  this.fieldLabelText,
  this.keyboardType,
  this.restorationId,
  this.onDatePickerModeChange,
  this.switchToInputEntryModeIcon,
  this.switchToCalendarEntryModeIcon,
})  : initialDate =
          initialDate == null ? null : PersianDateUtils.dateOnly(initialDate),
      firstDate = PersianDateUtils.dateOnly(firstDate),
      lastDate = PersianDateUtils.dateOnly(lastDate),
      currentDate = PersianDateUtils.dateOnly(currentDate ?? Jalali.now()) {
  assert(
    !this.lastDate.isBefore(this.firstDate),
    'lastDate ${this.lastDate} must be on or after firstDate ${this.firstDate}.',
  );
  assert(
    initialDate == null || !this.initialDate!.isBefore(this.firstDate),
    'initialDate ${this.initialDate} must be on or after firstDate ${this.firstDate}.',
  );
  assert(
    initialDate == null || !this.initialDate!.isAfter(this.lastDate),
    'initialDate ${this.initialDate} must be on or before lastDate ${this.lastDate}.',
  );
  assert(
    selectableDayPredicate == null ||
        initialDate == null ||
        selectableDayPredicate!(this.initialDate!),
    'Provided initialDate ${this.initialDate} must satisfy provided selectableDayPredicate',
  );
}