EmailInput constructor
EmailInput({
- Key? key,
- bool enabled = true,
- required TextEditingController controller,
- BoxConstraints? constraints,
- String labelText = "Email",
Implementation
EmailInput({
super.key,
super.enabled,
required this.controller,
this.constraints,
this.labelText = "Email",
}) : super(
builder: (field) {
return TextFormField(
enabled: enabled,
controller: controller,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a valid email address. Ex. testemail@hotmail.com';
}
var emailRegex = RegExp(r'\w+@\w+\.\w');
if (!emailRegex.hasMatch(value)) {
return 'Please enter email in the form "testemail@hotmail.com"';
}
return null;
},
decoration: InputDecoration(
labelText: labelText,
constraints: constraints,
border: const OutlineInputBorder(),
),
);
},
);