parse static method

DateTimeOrDuration parse(
  1. String textValue,
  2. ValueType type
)

Implementation

static DateTimeOrDuration parse(String textValue, ValueType type) {
  DateTime? dateTime;
  IsoDuration? duration;
  if (type == ValueType.dateTime) {
    dateTime = DateHelper.parseDateTime(textValue);
  } else if (type == ValueType.date) {
    dateTime = DateHelper.parseDate(textValue);
  } else if (type == ValueType.duration) {
    duration = IsoDuration.parse(textValue);
  } else {
    throw FormatException(
        'Unsupported type for DateTimeOrDuration: $type with text [$textValue].');
  }
  return DateTimeOrDuration(dateTime, duration);
}