DOBInputField constructor
DOBInputField({
- Key? key,
- DateTime? initialDate,
- required DateTime firstDate,
- required DateTime lastDate,
- bool showCursor = true,
- Radius? cursorRadius,
- double cursorWidth = 2.0,
- Color cursorColor = Colors.black,
- ValueChanged<
DateTime> ? onDateSubmitted, - bool showLabel = false,
- DateFormatType dateFormatType = DateFormatType.DDMMYYYY,
- InputDecoration inputDecoration = const InputDecoration(border: OutlineInputBorder(borderSide: BorderSide.none), filled: true, fillColor: Colors.white, counterText: '', hintText: 'MM/DD/YYYY'),
- ValueChanged<
DateTime> ? onDateSaved, - AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
- TextAlign textAlign = TextAlign.left,
- SelectableDayPredicate? selectableDayPredicate,
- String? errorFormatText,
- String? errorInvalidText,
- String? fieldHintText,
- TextStyle? style,
- String? fieldLabelText,
- bool autofocus = false,
Implementation
DOBInputField({
Key? key,
DateTime? initialDate,
required DateTime firstDate,
required DateTime lastDate,
this.showCursor = true,
this.cursorRadius,
this.cursorWidth = 2.0,
this.cursorColor = Colors.black,
this.onDateSubmitted,
this.showLabel = false,
this.dateFormatType = DateFormatType.DDMMYYYY,
this.inputDecoration = const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide.none,
),
filled: true,
fillColor: Colors.white,
counterText: '',
hintText: 'MM/DD/YYYY',
),
this.onDateSaved,
this.autovalidateMode = AutovalidateMode.onUserInteraction,
this.textAlign = TextAlign.left,
this.selectableDayPredicate,
this.errorFormatText,
this.errorInvalidText,
this.fieldHintText,
this.style,
this.fieldLabelText,
this.autofocus = false,
}) : assert(firstDate != null),
assert(lastDate != null),
assert(autofocus != null),
initialDate =
initialDate != null ? DateUtils.dateOnly(initialDate) : null,
firstDate = DateUtils.dateOnly(firstDate),
lastDate = DateUtils.dateOnly(lastDate),
super(key: key) {
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.',
);
assert(
selectableDayPredicate == null ||
initialDate == null ||
selectableDayPredicate!(this.initialDate!),
'Provided initialDate ${this.initialDate} must satisfy provided selectableDayPredicate.',
);
}