DateFormField constructor

DateFormField({
  1. Key? key,
  2. String label = 'Date',
  3. DateTime? initialDate,
  4. DateTime? firstDate,
  5. DateTime? lastDate,
  6. required ValueChanged<DateTime> onDateChanged,
  7. String dateDisplayFormat = 'dd/MM/yyyy',
  8. String timeDisplayFormat = 'HH:mm:ss',
  9. InputBorder inputBorder = const UnderlineInputBorder(),
  10. 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!),
  );
}