extension_general_lib_countDownFromDateTime method
Example:
DateTime.now().add(Duration(days: 10)).extension_general_lib_countDownFromDateTime(
dateTime: DateTime.now(),
);
result: example 1 days 5 minutes 5 seconds
Implementation
String extension_general_lib_countDownFromDateTime({
required DateTime dateTime,
}) {
try {
Duration duration = difference(dateTime);
String message = "";
if (duration.inDays >= 1) {
message += "${duration.inDays} Days";
}
if (duration.inHours >= 1) {
message += " ${23 - dateTime.hour} Hours";
}
if (duration.inMinutes >= 1) {
message += " ${59 - dateTime.minute} Minutes";
}
if (duration.inSeconds >= 1) {
message += " ${59 - dateTime.second} Seconds";
}
return message.trim();
} catch (e) {}
return "";
}