CalendarDatePicker2 constructor
CalendarDatePicker2({
- required CalendarDatePicker2Config config,
- required List<
DateTime?> value, - ValueChanged<
List< ? onValueChanged,DateTime?> > - Future onChange()?,
- DateTime? displayedMonthDate,
- ValueChanged<
DateTime> ? onDisplayedMonthChanged, - Key? key,
Implementation
CalendarDatePicker2({
required this.config,
required this.value,
this.onValueChanged,
// this.onDatesChanged,
this.onChange,
this.displayedMonthDate,
this.onDisplayedMonthChanged,
Key? key,
}) : super(key: key) {
const valid = true;
const invalid = false;
if (config.calendarType == CalendarDatePicker2Type.single) {
assert(value.length < 2,
'Error: single date picker only allows maximum one initial date');
}
if (config.calendarType == CalendarDatePicker2Type.range &&
value.length > 1) {
final isRangePickerValueValid = value[0] == null
? (value[1] != null ? invalid : valid)
: (value[1] != null
? (value[1]!.isBefore(value[0]!) ? invalid : valid)
: valid);
assert(
isRangePickerValueValid,
'Error: range date picker must has start date set before setting end date, and start date must before end date.',
);
}
}