isSameDate function Null safety

bool isSameDate(
  1. dynamic date1,
  2. dynamic date2
)

Check the dates are equal or not.

Implementation

bool isSameDate(dynamic date1, dynamic date2) {
  if (date2 == date1) {
    return true;
  }

  if (date1 == null || date2 == null) {
    return false;
  }

  if (date1 is HijriDateTime && date2 is HijriDateTime) {
    return date1.month == date2.month &&
        date1.year == date2.year &&
        date1.day == date2.day &&
        date1._date == date2._date;
  }

  return date1.month == date2.month &&
      date1.year == date2.year &&
      date1.day == date2.day;
}