DatePicker constructor

const DatePicker(
  1. DateTime startDate, {
  2. Key? key,
  3. double width = 60,
  4. double height = 80,
  5. DatePickerController? controller,
  6. TextStyle monthTextStyle = defaultMonthTextStyle,
  7. TextStyle dayTextStyle = defaultDayTextStyle,
  8. TextStyle dateTextStyle = defaultDateTextStyle,
  9. Color selectedTextColor = Colors.white,
  10. Color selectionColor = AppColors.defaultSelectionColor,
  11. Color deactivatedColor = AppColors.defaultDeactivatedColor,
  12. DateTime? initialSelectedDate,
  13. List<DateTime>? activeDates,
  14. List<DateTime>? inactiveDates,
  15. int daysCount = 500,
  16. DateChangeListener? onDateChange,
  17. String locale = "en_US",
  18. CalendarType calendarType = CalendarType.gregorianDate,
  19. TextDirection? directionality,
  20. bool showPastDates = false,
  21. SelectionMode selectionMode = SelectionMode.single,
  22. List<DateTime>? selectedDates,
  23. SelectionChangeListener? onSelectionChange,
  24. Color rangeColor = AppColors.defaultRangeColor,
  25. Color? rangeTextColor,
  26. DateGranularity granularity = DateGranularity.day,
  27. int? firstDayOfWeek,
})

Implementation

const DatePicker(
  this.startDate, {
  super.key,
  this.width = 60,
  this.height = 80,
  this.controller,
  this.monthTextStyle = defaultMonthTextStyle,
  this.dayTextStyle = defaultDayTextStyle,
  this.dateTextStyle = defaultDateTextStyle,
  this.selectedTextColor = Colors.white,
  this.selectionColor = AppColors.defaultSelectionColor,
  this.deactivatedColor = AppColors.defaultDeactivatedColor,
  this.initialSelectedDate,
  this.activeDates,
  this.inactiveDates,
  this.daysCount = 500,
  this.onDateChange,
  this.locale = "en_US",
  this.calendarType = CalendarType.gregorianDate,
  this.directionality,
  this.showPastDates = false,
  this.selectionMode = SelectionMode.single,
  this.selectedDates,
  this.onSelectionChange,
  this.rangeColor = AppColors.defaultRangeColor,
  this.rangeTextColor,
  this.granularity = DateGranularity.day,
  this.firstDayOfWeek,
})  : assert(
          activeDates == null || inactiveDates == null,
          "Can't "
          "provide both activated and deactivated dates List at the same time."),
      assert(
          selectionMode == SelectionMode.single ||
              initialSelectedDate == null,
          "initialSelectedDate only applies to SelectionMode.single. "
          "Use selectedDates with multiple/range."),
      assert(
          selectionMode != SelectionMode.single || selectedDates == null,
          "selectedDates requires SelectionMode.multiple or .range. "
          "Use initialSelectedDate in single mode."),
      assert(
          selectedDates == null ||
              selectionMode != SelectionMode.range ||
              selectedDates.length <= 2,
          "In range mode selectedDates must be [], [start] or [start, end]."),
      assert(
          firstDayOfWeek == null ||
              (firstDayOfWeek >= DateTime.monday &&
                  firstDayOfWeek <= DateTime.sunday),
          "firstDayOfWeek must be a DateTime weekday constant "
          "(DateTime.monday..DateTime.sunday)."),
      assert(
          calendarType == CalendarType.gregorianDate ||
              granularity == DateGranularity.day,
          "Week/month granularity is not supported with "
          "CalendarType.persianDate yet.");