class InputDate extends FormField<String> {
InputDate({
Key? key,
TextEditingController? controller,
FormFieldValidator<String>? validator,
Function(String?)? onSaved,
DateTime? initialValue,
required String label,
}) : super(
key: key,
validator: validator,
onSaved: onSaved,
builder: (field) {
return Column(
children: [
TextField(
controller: controller == null ? controller : newController,
onTap: () async {
final DateTime? pickedDate = await showDatePicker(
context: field.context,
initialDate: DateTime.now(),
firstDate: DateTime(
1000,
),
lastDate: DateTime(1999),
);
if (pickedDate != null) {
final formattedDate =
DateFormat('dd-MM-yyyy').format(pickedDate);
controller.text =
DateFormat('dd-MM-yyyy').format(formattedDate);
}
},
how do i make the controller inside the widget class Input Date extends > FormField optional? can you help
I have tried many times but got lost