calculateAge function

int calculateAge(
  1. DateTime birthDate
)

Implementation

int calculateAge(DateTime birthDate) {
  final now = DateTime.now();
  int age = now.year - birthDate.year;
  if (now.month < birthDate.month ||
      (now.month == birthDate.month && now.day < birthDate.day)) {
    age--;
  }
  // return age;
  return age;
}