PersianInputDatePickerFormField constructor
PersianInputDatePickerFormField({
- Key? key,
- Jalali? initialDate,
- required Jalali firstDate,
- required Jalali lastDate,
- ValueChanged<
Jalali> ? onDateSubmitted, - ValueChanged<
Jalali> ? onDateSaved, - PersianSelectableDayPredicate? selectableDayPredicate,
- String? errorFormatText,
- String? errorInvalidText,
- String? fieldHintText,
- String? fieldLabelText,
- TextInputType? keyboardType,
- bool autofocus = false,
- bool acceptEmptyDate = false,
- FocusNode? focusNode,
Creates a TextFormField configured to accept and validate a date.
If the optional initialDate
is provided, then it will be used to populate
the text field. If the fieldHintText
is provided, it will be shown.
If initialDate
is provided, it must not be before firstDate
or after
lastDate
. If selectableDayPredicate
is provided, it must return true
for initialDate
.
firstDate
must be on or before lastDate
.
Implementation
PersianInputDatePickerFormField({
super.key,
Jalali? initialDate,
required Jalali firstDate,
required Jalali lastDate,
this.onDateSubmitted,
this.onDateSaved,
this.selectableDayPredicate,
this.errorFormatText,
this.errorInvalidText,
this.fieldHintText,
this.fieldLabelText,
this.keyboardType,
this.autofocus = false,
this.acceptEmptyDate = false,
this.focusNode,
}) : initialDate =
initialDate != null ? PersianDateUtils.dateOnly(initialDate) : null,
firstDate = PersianDateUtils.dateOnly(firstDate),
lastDate = PersianDateUtils.dateOnly(lastDate) {
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.',
);
}