dateToFormattedDate static method

String dateToFormattedDate(
  1. String? date,
  2. bool showYear, {
  3. bool? full,
})

Implementation

static String dateToFormattedDate(String? date, bool showYear, {bool? full}) {
  if(date == null) return '';
  DateTime dateTime = DateTime.parse(date).toLocal();
  String formattedDate;
  showYear
      ? formattedDate = DateFormat.yMMMd().format(dateTime)
      : formattedDate = DateFormat.MMMd().format(dateTime);
  if(full != null){
    formattedDate = DateFormat.yMMMMd().format(dateTime);
  }
  return formattedDate;
}