DatePicker constructor
const
DatePicker(
- DateTime startDate, {
- Key? key,
- double width = 60,
- double height = 80,
- DatePickerController? controller,
- TextStyle monthTextStyle = defaultMonthTextStyle,
- TextStyle dayTextStyle = defaultDayTextStyle,
- TextStyle dateTextStyle = defaultDateTextStyle,
- Color selectedTextColor = Colors.white,
- Color selectionColor = AppColors.defaultSelectionColor,
- Color deactivatedColor = AppColors.defaultDeactivatedColor,
- DateTime? initialSelectedDate,
- List<
DateTime> ? activeDates, - List<
DateTime> ? inactiveDates, - int daysCount = 500,
- DateChangeListener? onDateChange,
- String locale = "en_US",
- CalendarType calendarType = CalendarType.gregorianDate,
- TextDirection? directionality,
- bool showPastDates = false,
- SelectionMode selectionMode = SelectionMode.single,
- List<
DateTime> ? selectedDates, - SelectionChangeListener? onSelectionChange,
- Color rangeColor = AppColors.defaultRangeColor,
- Color? rangeTextColor,
- DateGranularity granularity = DateGranularity.day,
- 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.");