compareToSafely method
Safe comparison method that returns null if either operand is null Useful when you want to explicitly handle null cases
Implementation
int? compareToSafely(DateTime? other) {
if (this == null || other == null) return null;
return this!.compareTo(other);
}