age property

int get age

Calcula la edad actual del paciente a partir de birthdate, ajustando si aún no ha cumplido años en el año en curso.

Implementation

int get age {
  final today = DateTime.now();
  int age = today.year - birthdate.year;
  if (today.month < birthdate.month ||
      (today.month == birthdate.month && today.day < birthdate.day)) {
    age--;
  }
  return age;
}