toDateTime method

DateTime? toDateTime({
  1. DateTime? fallback,
})

Try to parse to DateTime, fallback to null or fallback

Implementation

DateTime? toDateTime({DateTime? fallback}) {
  if (this == null) return fallback;
  return DateTime.tryParse(toString()) ?? fallback;
}