PasswordElement constructor

PasswordElement({
  1. String? id,
  2. String? initValue,
  3. Validation? passwordValidator,
  4. String? label,
  5. String? hint,
  6. PasswordElementDecoration? decorationPasswordElement,
  7. String? errorMsg,
  8. bool enableShowPassword = true,
  9. bool? isRequired,
  10. int minLength = 6,
  11. bool? hasUppercase,
  12. bool? hasSpecialCharacter,
  13. bool? hasDigits,
  14. PasswordError? errors,
  15. bool readOnly = false,
  16. EdgeInsets padding = const EdgeInsets.all(2.0),
  17. bool visibility = true,
})

Implementation

PasswordElement({
  String? id,
  this.initValue,
  this.passwordValidator,
  this.label,
  this.hint,
  this.decorationPasswordElement,
  this.errorMsg,
  this.enableShowPassword = true,
  this.isRequired,
  int minLength = 6,
  this.hasUppercase,
  this.hasSpecialCharacter,
  this.hasDigits,
  this.errors,
  this.readOnly = false,
  this.padding = const EdgeInsets.all(2.0),
  bool visibility = true,
}) : super(
        id: id,
        initValue: initValue,
        label: label,
        hint: hint,
        onTap: null,
        readOnly: readOnly,
        typeInput: TypeInput.Password,
        validator: passwordValidator ??
            (password) {
              if (password != null) {
                if (password.isNotEmpty) {
                  if (password.length < minLength) {
                    return errors?.minLengthErrorMsg;
                  } else if (RegExp(Patterns.upperAlpha).stringMatch(password) == null &&
                      hasUppercase!) {
                    return errors?.uppercaseErrorMsg ?? "";
                  } else if (RegExp(Patterns.specialChar).stringMatch(password) == null &&
                      hasSpecialCharacter!) {
                    return errors?.specialCharacterErrorMsg ?? "";
                  } else if (RegExp(Patterns.digitPattern).stringMatch(password) == null &&
                      hasDigits!) {
                    return errors?.digitsErrorMsg ?? "";
                  }
                } else if (isRequired!) {
                  return errors?.requiredErrorMsg ?? "this field is Required";
                }
              }
              return null;
            },
        visibility: visibility,
      );