toDateTime static method

DateTime toDateTime(
  1. dynamic d,
  2. DateTime def, {
  3. TimeUnit unit = TimeUnit.seconds,
})

Converts a dynamic value to a non-nullable DateTime.

d - The dynamic value to be converted. def - The default DateTime value if conversion fails. unit - The time unit of the input value (default is seconds). Returns a DateTime.

Implementation

static DateTime toDateTime(
  dynamic d,
  DateTime def, {
  TimeUnit unit = TimeUnit.seconds,
}) {
  return toDateTimeN(d, unit: unit) ?? def;
}