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

A versatile Flutter TextFormField widget for handling email and phone number input with ease.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);

  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Ephone Field Demo',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Ephone Field Demo'),
        ),
        body: Form(
          key: _formKey,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 20),
                child: EPhoneField(
                  title: "Select Country",
                  menuType: PickerMenuType.bottomSheet,
                  initialCountry: Country.afghanistan,
                  emailValidator: (String? email) {
                    if (email == null || email.isEmpty) {
                      return 'Email is required';
                    }
                    return null;
                  },
                  phoneValidator: (String? phone) {
                    if (phone == null || phone.isEmpty) {
                      return 'Phone is required';
                    }
                    return null;
                  },
                  pickerHeight: CountryPickerHeigth.h50, // Not Effective in PickerMenuType.page
                  onCountryChanged: (Country? country) {
                    // Add your code here after country selected
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
140
pub points
50%
popularity

Publisher

verified publisherdesxz.dev

A versatile Flutter TextFormField widget for handling email and phone number input with ease.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ephone_field