hcCalculateAge function

String hcCalculateAge(
  1. String birthDateString
)

Calculate Age

Implementation

String hcCalculateAge(String birthDateString) {
  String datePattern = "dd-MM-yyyy";
  DateTime today = DateFormat(datePattern).parse(DateTime.now().toString());
  DateTime birthDate = DateFormat(datePattern).parse(birthDateString);
  String year = (today.year - birthDate.year).toString();
  String month = (today.month - birthDate.month).abs().toString();
  return '$year year, $month months';
}