hcCheckMature function

bool hcCheckMature(
  1. String birthDateString
)

Check Age if age is greater than 18 year or not

Implementation

bool hcCheckMature(String birthDateString) {
  String datePattern = "dd-MM-yyyy";
  DateTime today = DateTime.now();
  DateTime birthDate = DateFormat(datePattern).parse(birthDateString);
  // Date to check but moved 18 years ahead
  DateTime adultDate = DateTime(
    birthDate.year + 18,
    birthDate.month,
    birthDate.day,
  );
  return adultDate.isBefore(today);
}