isValidDate static method
Validates a date string in the format YYYY-MM-DD. Returns true if the date is valid, false otherwise.
Implementation
static bool isValidDate(String date) {
try {
final parts = date.split('-');
if (parts.length != 3) return false;
final year = int.parse(parts[0]);
final month = int.parse(parts[1]);
final day = int.parse(parts[2]);
final dateTime = DateTime(year, month, day);
return dateTime.year == year &&
dateTime.month == month &&
dateTime.day == day;
} catch (e) {
return false;
}
}