toDateTimeOr method

DateTime toDateTimeOr(
  1. DateTime defaultValue, {
  2. dynamic mapKey,
  3. int? listIndex,
  4. String? format,
  5. String? locale,
  6. bool autoDetectFormat = false,
  7. bool useCurrentLocale = false,
  8. bool utc = false,
  9. DynamicConverter<DateTime>? converter,
})

Converts to DateTime, falling back to defaultValue on failure.

Implementation

DateTime toDateTimeOr(
  DateTime defaultValue, {
  dynamic mapKey,
  int? listIndex,
  String? format,
  String? locale,
  bool autoDetectFormat = false,
  bool useCurrentLocale = false,
  bool utc = false,
  DynamicConverter<DateTime>? converter,
}) =>
    tryToDateTime(
      mapKey: mapKey,
      listIndex: listIndex,
      format: format,
      locale: locale,
      autoDetectFormat: autoDetectFormat,
      useCurrentLocale: useCurrentLocale,
      utc: utc,
      defaultValue: defaultValue,
      converter: converter,
    ) ??
    defaultValue;