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

A simple, styleable, and validated email input field for Flutter.

example/lib/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 Example',
      theme: ThemeData(
        brightness: Brightness.dark,
        primarySwatch: Colors.deepPurple,
      ),
      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>();

  void _submitForm() {
    if (_formKey.currentState!.validate()) {
      // Validation passed! Proceed with submission logic.
      ScaffoldMessenger.of(
        context,
      ).showSnackBar(const SnackBar(content: Text('Email is valid!')));
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('EZ Email Field Demo')),
      body: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Form(
          key: _formKey,
          autovalidateMode: AutovalidateMode.onUserInteraction,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              // Simple usage
              const EZEmailField(),
              const SizedBox(height: 20),

              // Custom usage with custom styling and label
              const EZEmailField(
                labelText: 'User ID Email',
                hintText: 'e.g., john.doe@work.com',
                decoration: InputDecoration(
                  border: UnderlineInputBorder(),
                  fillColor: Color(0x808080FF),
                  filled: true,
                ),
              ),
              const SizedBox(height: 32),
              ElevatedButton(
                onPressed: _submitForm,
                style: ElevatedButton.styleFrom(
                  padding: const EdgeInsets.symmetric(vertical: 16),
                ),
                child: const Text('Validate & Submit'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
39
downloads

Documentation

API reference

Publisher

verified publisherezinner.com

Weekly Downloads

A simple, styleable, and validated email input field for Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ez_email_field