endTimeEnumToTimeOfDay function
converts an endTimeEnum value and endTime to a DateTime object representing the adjusted time of day returns the adjusted DateTime value, or null if the conversion is not possible
Implementation
DateTime? endTimeEnumToTimeOfDay(String endTimeEnum, DateTime? endTime) {
// ignore: unnecessary_null_comparison
if (endTimeEnum == null ||
// ignore: prefer_is_empty
endTimeEnum.trim().length == 0 ||
endTime == null) {
return endTime;
}
switch (endTimeEnum.toString()) {
case 'LOC_END_TIME_ENUM.TEN_MIN':
return endTime.add(const Duration(minutes: 10));
case 'LOC_END_TIME_ENUM.AFTER_EVERY_ONE_REACHED':
return endTime;
case 'LOC_END_TIME_ENUM.AT_EOD':
var nextDay = DateTime(endTime.year, endTime.month, endTime.day + 1);
var addDuration = nextDay.difference(endTime);
return endTime.add(addDuration);
}
return null;
}