endTimeEnumToTimeOfDay function

DateTime? endTimeEnumToTimeOfDay(
  1. String endTimeEnum,
  2. DateTime? endTime
)

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(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);
  }
}