compose static method

DateTime? compose({
  1. required dynamic date,
  2. required dynamic time,
  3. String? offset,
})

Implementation

static DateTime? compose({required dynamic date, required dynamic time, String? offset}) {
  DateTime? dateAt = toDate(date);
  DateTime? timeAt = toDate(time);
  DateTime? dateTime;

  if (dateAt != null && timeAt != null && !timeAt.isMidnight) {
    dateTime = DateTime(dateAt.year, dateAt.month, dateAt.day, timeAt.hour, timeAt.minute);
  } else if (dateAt == null && timeAt != null) {
    dateTime = timeAt;
  } else {
    dateTime = dateAt;
  }

  return offset == null ? dateTime : dateTime?.add(Duration(minutes: int.parse(offset)));
}