pickDate method
Implementation
Future<String?> pickDate(
{String dateFormatChange="dd-MM-yyyy",DateTime? initialDate, DateTime? firstDate, DateTime? lastDate}) async {
final pickedDate = await showDatePicker(
context: this,
initialDate: initialDate ?? DateTime.now(),
firstDate: firstDate ?? DateTime(1990),
lastDate: lastDate ?? DateTime(2100),
);
if (pickedDate != null) {
// Format the picked date to DD-MM-YYYY
final DateFormat dateFormat = DateFormat(dateFormatChange.toString());
return dateFormat.format(pickedDate);
}
return null;
}