compareToSafely method

int? compareToSafely(
  1. DateTime? other
)

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);
}