hcTimeDifference function

String hcTimeDifference(
  1. String startTime,
  2. String endTime
)

Time Difference

Implementation

String hcTimeDifference(String startTime, String endTime) {
  var format = DateFormat("HH:mm");
  DateTime now = DateTime.now();
  var sTime = format.parse(startTime);
  var eTime = format.parse(endTime);
  sTime = DateTime(now.year, now.month, now.day, sTime.hour, sTime.minute);
  eTime = DateTime(now.year, now.month, now.day, eTime.hour, eTime.minute);
  if (sTime.isAfter(eTime)) {
    return "${sTime.difference(eTime).inMinutes}";
  } else {
    return "${eTime.difference(sTime).inMinutes}";
  }
}