ez_email_field 0.0.2 copy "ez_email_field: ^0.0.2" to clipboard
ez_email_field: ^0.0.2 copied to clipboard

A pre-validated, highly customizable email text field with built-in regex and error handling.

example/main.dart

import 'package:ez_email_field/ez_email_field.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'EZ Email Field Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal),
        useMaterial3: true,
      ),
      home: const EmailFormScreen(),
    );
  }
}

class EmailFormScreen extends StatefulWidget {
  const EmailFormScreen({super.key});

  @override
  State<EmailFormScreen> createState() => _EmailFormScreenState();
}

class _EmailFormScreenState extends State<EmailFormScreen> {
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  final TextEditingController _controller = TextEditingController();

  void _submitForm() {
    if (_formKey.currentState!.validate()) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('Valid Email: ${_controller.text}')),
      );
    }
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('EZ Email Field Demo'),
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(24.0),
        child: Form(
          key: _formKey,
          autovalidateMode: AutovalidateMode.onUserInteraction,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              const Text(
                '1. Basic Usage',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
              ),
              const SizedBox(height: 8),
              const EZEmailField(),
              const Divider(height: 32),
              const Text(
                '2. Custom Styling & Label',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
              ),
              const SizedBox(height: 8),
              const EZEmailField(
                labelText: 'Work Email',
                hintText: 'john.doe@company.com',
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  prefixIcon: Icon(Icons.work_outline),
                  filled: true,
                ),
              ),
              const Divider(height: 32),
              const Text(
                '3. Custom Validation (e.g., Corporate Only)',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
              ),
              const SizedBox(height: 8),
              EZEmailField(
                controller: _controller,
                customValidator: (value) {
                  if (value != null && !value.endsWith('@ezinner.com')) {
                    return 'Must be an @ezinner.com email address';
                  }
                  return null;
                },
                decoration: const InputDecoration(
                  labelText: 'Corporate Email',
                  helperText: 'Must end with @ezinner.com',
                ),
              ),
              const Divider(height: 32),
              SizedBox(
                width: double.infinity,
                child: FilledButton.icon(
                  onPressed: _submitForm,
                  icon: const Icon(Icons.check),
                  label: const Text('Validate All'),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
16
downloads

Publisher

verified publisherezinner.com

Weekly Downloads

A pre-validated, highly customizable email text field with built-in regex and error handling.

Repository (GitHub)
View/report issues

Topics

#flutter #ez-flutter #email #form #input

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com
thanks.dev
buymeacoffee.com

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ez_email_field