how to compare two date flutter datetime code example

Example 1: 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;
  }
}

Example 2: compare date month and year in datetime in flutter

Since I asked this, extension methods have been released in Dart. I would now 
implement option 1 as an extension method:

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

About Extensions :
https://dart.dev/guides/language/extension-methods

Tags:

Dart Example