safeParse static method
Implementation
static DateTime? safeParse(String? str) {
if (str == null) {
return null;
}
const dateFormatPatterns = [
'EEE, d MMM yyyy HH:mm:ss Z',
];
try {
return DateTime.parse(str);
} catch (_) {
for (final pattern in dateFormatPatterns) {
try {
final format = DateFormat(pattern);
return format.parse(str);
} catch (_) {}
}
}
return null;
}