email_textfield 0.0.1 copy "email_textfield: ^0.0.1" to clipboard
email_textfield: ^0.0.1 copied to clipboard

A customizable Flutter email text field with validation, styles, and configurable borders.

README.md #

email_textfield #

Pub Version License: MIT

A customizable Flutter EmailTextField widget with built-in validation, prefix icon support, and flexible styling (label/hint/error styles, border radius and colors).


Features #

  • ✅ Email validation with sensible default
  • 🎨 Custom label, hint and error text styles
  • 🔲 Custom border radius and colors (normal, focused, error)
  • ✉️ Prefix icon (default Icons.email) and override support
  • ✅ Simple to drop into forms and examples included

Installation #

Add the package to your pubspec.yaml (replace with the published version when available):

dependencies:
  email_textfield: ^0.0.1

Then run:

flutter pub get

Or add locally during development:

dependencies:
  email_textfield:
    path: ../email_textfield

Usage #

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

class MyForm extends StatelessWidget {
  final controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Form(
      child: Column(
        children: [
          EmailTextField(
            controller: controller,
            label: "Email Address",
            hint: "example@gmail.com",
            prefixIcon: const Icon(Icons.alternate_email),

            // Optional customizations
            labelStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
            hintStyle: const TextStyle(color: Colors.grey),
            errorStyle: const TextStyle(color: Colors.redAccent, fontSize: 12),

            borderRadius: 10,
            borderColor: Colors.grey,
            focusedBorderColor: Colors.blue,
            errorBorderColor: Colors.redAccent,
          ),
        ],
      ),
    );
  }
}

API #

EmailTextField constructor parameters #

  • TextEditingController? controller — controller for the field.
  • String? hint — hint text (default: "Enter email").
  • String? label — label text (default: "Email").
  • void Function(String)? onChanged — called when value changes.
  • String? Function(String?)? validator — custom validator. If omitted, a sensible email validator is used.
  • Widget? prefixIcon — optional prefix widget. Defaults to Icon(Icons.email).

Customization

  • TextStyle? labelStyle — custom label text style.
  • TextStyle? hintStyle — custom hint text style.
  • TextStyle? errorStyle — custom error text style.
  • double borderRadius — border radius for the field (default: 8.0).
  • Color? borderColor — normal border color.
  • Color? focusedBorderColor — focused border color.
  • Color errorBorderColor — error border color (default: Colors.red).

Example (example/lib/main.dart) #

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

void main() => runApp(const ExampleApp());

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

  @override
  Widget build(BuildContext context) {
    final emailController = TextEditingController();

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('EmailTextField Example')),
        body: Padding(
          padding: const EdgeInsets.all(16),
          child: Form(
            child: Column(
              children: [
                EmailTextField(controller: emailController),
                const SizedBox(height: 20),
                ElevatedButton(
                  onPressed: () {
                    final email = emailController.text;
                    ScaffoldMessenger.of(context).showSnackBar(
                      SnackBar(content: Text('Entered Email: $email')),
                    );
                  },
                  child: const Text('Submit'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

CHANGELOG (summary) #

See CHANGELOG.md for a full history. Example:

## 0.0.1
- Initial release with EmailTextField widget and customization options

Contributing #

Contributions welcome — open issues or PRs on GitHub. Please follow these guidelines:

  1. Fork the repo
  2. Create a branch feature/your-feature
  3. Add tests and update CHANGELOG.md
  4. Create a PR with a clear description

License #

This project is licensed under the MIT License — see the LICENSE file for details.


Contact #

If you have questions, open an issue at the repository or contact the maintainer via your GitHub profile.


0
likes
150
points
33
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A customizable Flutter email text field with validation, styles, and configurable borders.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on email_textfield