isYesterday property

bool get isYesterday

Returns true if the given date is yesterday.

Example:

DateTime yesterday = DateTime.now().subtract(Duration(days: 1));
print(yesterday.isYesterday); // Output: true

Implementation

bool get isYesterday {
  if (isNull) {
    return false;
  }
  final nowDate = DateTime.now();
  return year == nowDate.year &&
      month == nowDate.month &&
      day == nowDate.day - 1;
}