DateFormField constructor
DateFormField({
- Key? key,
- String label = 'Date',
- DateTime? initialDate,
- DateTime? firstDate,
- DateTime? lastDate,
- required ValueChanged<
DateTime> onDateChanged, - String dateDisplayFormat = 'dd/MM/yyyy',
- String timeDisplayFormat = 'HH:mm:ss',
- InputBorder inputBorder = const UnderlineInputBorder(),
- DateFormFieldType type = DateFormFieldType.date,
Implementation
DateFormField({
Key? key,
this.label = 'Date',
this.initialDate,
this.firstDate,
this.lastDate,
required this.onDateChanged,
this.dateDisplayFormat = 'dd/MM/yyyy',
this.timeDisplayFormat = 'HH:mm:ss',
this.inputBorder = const UnderlineInputBorder(),
this.type = DateFormFieldType.date,
}) : super(key: key) {
initialDate ??= DateTime.now();
firstDate ??= DateTime.now();
lastDate ??= DateTime.now().add(const Duration(days: 30));
if (type == DateFormFieldType.time) {
dateDisplayFormat = timeDisplayFormat;
}
_controller = TextEditingController(
text: DateFormat(dateDisplayFormat).format(initialDate!),
);
}