bool hasMinSpecialChar(String password, int specialCount) { String pattern = r"^(.*?[$&+,\:;/=?@#|'<>.^*()_%!-]){" + specialCount.toString() + ",}"; return password.contains(new RegExp(pattern)); }