toFormattedDate method

String toFormattedDate({
  1. String outputFormat = 'dd/MM/yyyy',
})

Implementation

String toFormattedDate({String outputFormat = 'dd/MM/yyyy'}) {
  if (isNotNullOrEmpty) {
    try {
      final date = DateTime.parse(this!);
      return DateFormat(outputFormat).formatLocalized(date);
    } catch (e) {
      return this!;
    }
  } else {
    return '';
  }
}