toDurationWithDefault static method

Duration toDurationWithDefault(
  1. dynamic value,
  2. Duration defaultValue
)

Converts value into Date or returns default when conversion is not possible.

  • value the value to convert.
  • defaultValue the default value. Returns Date value or default when conversion is not supported.

See toNullableDuration

Implementation

static Duration toDurationWithDefault(value, Duration defaultValue) {
  var result = DurationConverter.toNullableDuration(value);
  return result ?? defaultValue;
}