toDateTime method

String toDateTime({
  1. String format = 'dd MMM yyyy | hh:mm aaa',
})

Implementation

String toDateTime({String format = 'dd MMM yyyy | hh:mm aaa'}) => length > 0
    ? DateFormat(format).format(DateTime.tryParse(this)?.toLocal() ??
        DateTime.fromMillisecondsSinceEpoch(
          int.parse(this),
        ).toLocal())
    : this;