formatDateAndTime static method
Formats a DateTime object to a string in the format 'dd/MM/yyyy at hh:mm'. If no date is provided, it defaults to the current date and time.
Implementation
static String formatDateAndTime(DateTime? date) {
date ??=
DateTime.now(); // Use current date and time if no date is provided.
final onlyDate = DateFormat('dd/MM/yyyy').format(date); // Format the date.
final onlyTime = DateFormat('hh:mm').format(date); // Format the time.
return '$onlyDate at $onlyTime'; // Combine date and time.
}