asDateTime function

DateTime? asDateTime(
  1. dynamic value, {
  2. String? format,
})

Implementation

DateTime? asDateTime(dynamic value, {String? format}){
  if(isNullOrEmpty(value)) return null;
  if(value is String){
    return stringToDate(value, dateFormat: format);
  }
  return DateTime.now();
}