formatDate static method

String formatDate(
  1. DateTime? date
)

Formats a DateTime object to a string in the format 'dd/MM/yyyy'. If no date is provided, it defaults to the current date.

Implementation

static String formatDate(DateTime? date) {
  date ??= DateTime.now(); // Use current date if no date is provided.
  final onlyDate = DateFormat('dd/MM/yyyy').format(date); // Format the date.
  return onlyDate;
}