formatDate method

String? formatDate({
  1. required String likeGiven,
})

formatDate(): Formats a DateTime object using a specified format string. The likeGiven parameter is used to provide a format hint, and the function detects the appropriate format based on the string's contents.

Implementation

String? formatDate({required String likeGiven}) {
  String dateFormat = likeGiven.detectDateFormat() ?? "dd-MM-yyyy";
  String formattedDate = DateFormat(dateFormat).format(this);
  return formattedDate;
}