age property
int
get
age
Returns the age in whole years from this date to now.
DateTime(1990, 5, 15).age // 33 (in 2024)
Implementation
int get age {
final now = DateTime.now();
var years = now.year - year;
if (now.month < month || (now.month == month && now.day < day)) {
years--;
}
return years;
}