toDuration method

Duration toDuration()

Tries convert the input to a Duration. It assumes the input format is HH:MM:SS.SSS. Throws ConvertStringToDurationEx on error.

Implementation

Duration toDuration() {
  if (input == null) {
    throw const _StringIsNullEx();
  }
  try {
    final duration = toDurationOrNull()!;
    return duration;
  } catch (_) {
    throw const _InvalidInputStringFormatEx();
  }
}