PasswordElement constructor
PasswordElement({
- String? id,
- String? initValue,
- Validation? passwordValidator,
- String? label,
- String? hint,
- PasswordElementDecoration? decorationPasswordElement,
- String? errorMsg,
- bool enableShowPassword = true,
- bool? isRequired,
- int minLength = 6,
- bool? hasUppercase,
- bool? hasSpecialCharacter,
- bool? hasDigits,
- PasswordError? errors,
- bool readOnly = false,
- EdgeInsets padding = const EdgeInsets.all(2.0),
- 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,
);