startTimeEnumToTimeOfDay function

DateTime? startTimeEnumToTimeOfDay(
  1. String startTimeEnum,
  2. DateTime? startTime
)

Implementation

DateTime? startTimeEnumToTimeOfDay(String startTimeEnum, DateTime? startTime) {
  // ignore: unnecessary_null_comparison
  if (startTimeEnum == null ||
      // ignore: prefer_is_empty
      startTimeEnum.trim().length == 0 ||
      startTime == null) {
    return startTime;
  }
  switch (startTimeEnum.toString()) {
    case 'LOC_START_TIME_ENUM.TWO_HOURS':
      return startTime.subtract(Duration(hours: 2));

    case 'LOC_START_TIME_ENUM.SIXTY_MIN':
      return startTime.subtract(Duration(minutes: 60));

    case 'LOC_START_TIME_ENUM.THIRTY_MIN':
      return startTime.subtract(Duration(minutes: 30));
  }
}