DatePicker constructor
DatePicker({
- Key? key,
- required DateTime? initialDate,
- required DateTime firstDate,
- required DateTime lastDate,
- DateTime? currentDate,
- required ValueChanged<
DateTime> onDateChanged, - DatePickerController? controller,
- ValueChanged<
DateTime> ? onDisplayedMonthChanged, - Color? enableTextColor,
- Color? disableTextColor,
- Color? selectedTextColor,
- Color? selectedColor,
- Color? backgroundColor,
- TextStyle? monthTextStyle,
- double? monthHeaderItemHeight,
- BoxShape selectedShape = BoxShape.circle,
- SelectableDayPredicate? selectableDayPredicate,
Implementation
DatePicker({
super.key,
required DateTime? initialDate,
required DateTime firstDate,
required DateTime lastDate,
DateTime? currentDate,
required this.onDateChanged,
this.controller,
this.onDisplayedMonthChanged,
this.enableTextColor,
this.disableTextColor,
this.selectedTextColor,
this.selectedColor,
this.backgroundColor,
this.monthTextStyle,
this.monthHeaderItemHeight,
this.selectedShape = BoxShape.circle,
this.selectableDayPredicate,
}) : initialDate =
initialDate == null ? null : DateUtils.dateOnly(initialDate),
firstDate = DateUtils.dateOnly(firstDate),
lastDate = DateUtils.dateOnly(lastDate),
currentDate = DateUtils.dateOnly(currentDate ?? DateTime.now()) {
assert(
!this.lastDate.isBefore(this.firstDate),
'lastDate ${this.lastDate} must be on or after firstDate ${this.firstDate}.',
);
assert(
this.initialDate == null || !this.initialDate!.isBefore(this.firstDate),
'initialDate ${this.initialDate} must be on or after firstDate ${this.firstDate}.',
);
assert(
this.initialDate == null || !this.initialDate!.isAfter(this.lastDate),
'initialDate ${this.initialDate} must be on or before lastDate ${this.lastDate}.',
);
assert(
selectableDayPredicate == null ||
this.initialDate == null ||
selectableDayPredicate!(this.initialDate!),
'Provided initialDate ${this.initialDate} must satisfy provided selectableDayPredicate.',
);
}