formatDateDMAHM static method

DateTime formatDateDMAHM(
  1. String date
)

Recebe String com formato 'dd-MM-aaaa hh-mm' e retorna o DateTime correspondente.

Implementation

static DateTime formatDateDMAHM(String date) {
  List<String> dataHora = date.split(' ');
  String data = dataHora[0];
  String hora = dataHora[1];

  List<String> dma = data.split('-');
  List<String> hm = hora.split(':');

  return DateTime(
    int.parse(dma[2]),
    int.parse(dma[1]),
    int.parse(dma[0]),
    int.parse(hm[0]),
    int.parse(hm[1]),
  );
}