dateToString static method

String? dateToString(
  1. DateTime? date, {
  2. String format = 'yyyy-MM-dd HH:mm',
  3. bool returnNull = false,
})

Implementation

static String? dateToString(DateTime? date,
    {String format = 'yyyy-MM-dd HH:mm', bool returnNull = false}) {
  if (date == null) return returnNull ? null : "";
  final DateFormat formatter = DateFormat(format);
  final String formatted = formatter.format(date);
  return formatted;
}