convertStringToDateTime function

Map<String, dynamic> convertStringToDateTime(
  1. Map<String, dynamic> map
)

Implementation

Map<String, dynamic> convertStringToDateTime(Map<String, dynamic> map) {
  for (var entry in map.entries) {
    if (entry.value is String) {
      try {
        DateTime parsedDateTime = DateTime.parse(entry.value);
        String formattedDateTime = parsedDateTime.toIso8601String();
        if (entry.value == formattedDateTime) {
          map[entry.key] = parsedDateTime;
        }
      } catch (e) {}
    }
  }
  return map;
}