tryFormat static method
Returns an empty string if DateFormat.format()
throws or date
is null.
Implementation
static String tryFormat(DateTime? date, DateFormat format) {
if (date != null) {
try {
return format.format(date);
} catch (e) {
// print('Error formatting date: $e');
}
}
return '';
}