EmailElement constructor
EmailElement({
- String? id,
- String? initValue,
- String? label,
- String? hint,
- DecorationElement? decorationElement,
- String errorEmailPattern = "invalid email",
- String errorEmailIsRequired = "email is empty",
- bool isRequired = false,
- bool readOnly = false,
- EdgeInsets padding = const EdgeInsets.all(2.0),
- bool visibility = true,
Implementation
EmailElement({
String? id,
this.initValue,
this.label,
this.hint,
this.decorationElement,
this.errorEmailPattern = "invalid email",
this.errorEmailIsRequired = "email is empty",
this.isRequired = false,
this.readOnly = false,
this.padding = const EdgeInsets.all(2.0),
bool visibility = true,
}) : super(
id: id,
initValue: initValue,
label: label,
typeInput: TypeInput.Email,
hint: hint,
decorationElement: decorationElement,
padding: padding,
readOnly: readOnly,
validator: (email) {
if (isRequired) {
if (email!.isEmpty) {
return errorEmailIsRequired;
}
}
if (email!.isNotEmpty) {
bool emailValid = RegExp(Patterns.emailPattern).hasMatch(email);
if (!emailValid) {
return errorEmailPattern;
}
}
return null;
},
visibility: visibility,
);