differenceTo method

Duration? differenceTo(
  1. DateTime? other
)

Safely calculates the difference between two nullable DateTime objects Returns null if either this or other is null, otherwise returns the Duration difference

Implementation

Duration? differenceTo(DateTime? other) {
  if (this != null && other != null) {
    return this!.difference(other);
  }
  return null;
}