formatterChatTime static method
Implementation
static String formatterChatTime(String? lastTime, String sendTime) {
try {
DateTime? dt = DateTime.tryParse(sendTime);
DateTime? pt = DateTime.tryParse(lastTime ?? "");
if (pt == null || dt == null) {
if (dt != null) {
return DateUtil.formatDate(dt, format: DateFormats.y_mo_d_h_m);
}
return "";
}
if (pt.day == dt.day) {
if (dt.difference(pt).inMinutes > 3) {
return DateUtil.formatDate(pt, format: DateFormats.h_m);
} else {
return "";
}
} else if (pt.year == dt.year) {
return DateUtil.formatDate(pt, format: DateFormats.mo_d_h_m);
} else {
return DateUtil.formatDate(pt, format: DateFormats.y_mo_d_h_m);
}
} catch (error) {
print(error.toString());
}
return "";
}