ultimoTreino method
- String? chave
O texto de "último treino": "hoje", "ontem", a data (dd/mm/aaaa) ou
"nenhum ainda" quando o resumo não tem um.
Implementation
String ultimoTreino(String? chave) {
final data = chave == null ? null : DateTime.tryParse(chave);
if (data == null) return 'nenhum ainda';
if (chave == ultimosDias(1).first) return 'hoje';
if (chave == ultimosDias(2).first) return 'ontem';
String dosDois(int n) => n.toString().padLeft(2, '0');
return '${dosDois(data.day)}/${dosDois(data.month)}/${data.year}';
}