dateToString static method
Converts a DateTime into a formatted string using the given format
.
Returns an empty string if date
is null.
Example:
DateTimeUtils.dateToString(DateTime.now(), format: "yyyy-MM-dd");
Implementation
static String dateToString(DateTime? date, {required String format}) {
if (date == null) {
return '';
}
return DateFormat(format).format(date);
}