formatDate method

String formatDate(
  1. DateTime date, {
  2. String? pattern,
})

Formats a DateTime object to a readable string.

Uses yyyy-MM-dd format by default.

Implementation

String formatDate(DateTime date, {String? pattern}) {
  final formatter = DateFormat(pattern ?? AppConstants.defaultDateFormat);
  return formatter.format(date);
}