ez_email_field 0.0.2
ez_email_field: ^0.0.2 copied to clipboard
A pre-validated, highly customizable email text field with built-in regex and error handling.
EZ Email Field #
A pre-validated, developer-friendly Flutter text field specifically designed for email input.
π The Problem #
Implementing email fields repeatedly involves:
- Regex Boilerplate: Copy-pasting the same email regex pattern into every form.
- Validation Logic: Writing the same
if (value.isEmpty) ... else if (!regex.hasMatch) ...logic. - Inconsistent UX: Different parts of the app might accept different email formats or show different error messages.
β The EZ Solution #
EZEmailField encapsulates best practices for email input into a single, drop-in widget:
- Built-in Validation: Comes with a robust, industry-standard regex for email validation out of the box.
- Defensive Defaults: Handles empty states and formatting errors automatically.
- Unified UX: Ensures email input behaves consistently across your entire application.
β¨ Features #
- Zero-Config Validation: Just drop it in a
Form, and it works. - Customizable Regex: Use the default pattern or supply your own
emailRegex. - Flexible Styling: Supports all standard
InputDecorationproperties. - Controller Support: Works with or without an external
TextEditingController.
π¦ Installation #
flutter pub add ez_email_field
π Usage #
Wrap it in a Form to enable validation:
Form(
key: _formKey,
child: Column(
children: [
EZEmailField(
controller: _emailController,
decoration: InputDecoration(labelText: 'Email Address'),
),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
// Handle valid submission
}
},
child: Text('Submit'),
)
],
),
)
Custom Validation Logic #
You can still add custom logic on top of the built-in validation:
EZEmailField(
customValidator: (value) {
if (value != null && !value.endsWith('@company.com')) {
return 'Corporate email required';
}
return null;
},
)
π€ Contributing #
Contributions are welcome! Please feel free to open an issue or submit a pull request on GitHub.
π License #
MIT License - see the LICENSE file for details.