how to check different between two date in dart code example

Example 1: dart datetime difference

//the birthday's date
 final birthday = DateTime(1967, 10, 12);
 final date2 = DateTime.now();
 final difference = date2.difference(birthday).inDays;

Example 2: how to check if two dates are same in flutter

extension DateOnlyCompare on DateTime {
  bool isSameDate(DateTime other) {
    return this.year == other.year && this.month == other.month
           && this.day == other.day;
  }
}

Tags:

Misc Example