isYesterday property
bool
get
isYesterday
判断日期是否为昨天
返回结果: 若日期为昨天,返回true,否则返回false。
示例:
DateTime yesterday = DateTime.now().subtract(Duration(days:1));
print(yesterday.isYesterday); // true
Implementation
bool get isYesterday {
final now = DateTime.now();
final yesterday = DateTime(now.year, now.month, now.day - 1);
return DateTime(year, month, day) == yesterday;
}