Search packages, repositories and app categories

Package detailsv1.0.4

international_phone_input

International Phone Number Input For Flutter. This packages validates phone number input value using the libphonenumber package.

30-day downloads
84
Likes
43
Pub points
40

Install package

flutter pub add international_phone_input

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package for handling international phone number input with built-in validation using the libphonenumber library. It provides a user-friendly interface to enter and format phone numbers according to country-specific standards, ensuring accurate data collection across global users. The package automatically detects the country based on input or a selected default, applies proper formatting, and validates the entered number in real time.

Use cases

  • Global user registration
  • International contact forms
  • Phone number verification workflows
  • Multi-region mobile applications
  • E-commerce checkout processes

Key features

  • Real-time phone number validation
  • Automatic country code detection
  • Formatted input with masking
  • Supports all major countries
  • Integration with libphonenumber

Suitable for

  • Apps targeting international audiences
  • Forms requiring valid phone numbers
  • Developers needing robust input validation
  • Projects using internationalization
  • Applications with compliance needs

Considerations

  • Requires internet for full country database lookup
  • May increase app size due to libphonenumber dependency
  • Limited customization of UI components
  • No offline validation support
  • Dependent on external library updates

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

international_phone_input

International Phone Number Input For Flutter

Usage

Just put the component in your application.

import 'package:international_phone_input/international_phone_input.dart';

String phoneNumber;
String phoneIsoCode;

void onPhoneNumberChange(String number, String internationalizedPhoneNumber, String isoCode) {
    setState(() {
       phoneNumber = number;
       phoneIsoCode = isoCode;
    });
}

// Default Widget with dropdown list
@override
 Widget build(BuildContext context) => Scaffold(
     body: Center(
       child: InternationalPhoneInput(
          onPhoneNumberChange: onPhoneNumberChange, 
          initialPhoneNumber: phoneNumber,
          initialSelection: phoneIsoCode,
          enabledCountries: ['+233', '+1']
       ),
     ),
 );

// Widget with text input only

 onValidPhoneNumber(
      String number, String internationalizedPhoneNumber, String isoCode) {
    setState(() {
      confirmedNumber = internationalizedPhoneNumber;
    });
  }

@override
 Widget build(BuildContext context) => Scaffold(
     body: Center(
       child:  InternationalPhoneInputText(
         onValidPhoneNumber: onValidPhoneNumber,
        ),
     ),
 );

// Widget with decoration
// Using decoration overwrites other styles such as hintStyle, hintText, etc.

@override
 Widget build(BuildContext context) => Scaffold(
     body: Center(
       child: InternationalPhoneInput(
          decoration: InputDecoration.collapsed(hintText: '(416) 123-4567'),
          onPhoneNumberChange: onPhoneNumberChange, 
          initialPhoneNumber: phoneNumber,
          initialSelection: phoneIsoCode,
          enabledCountries: ['+233', '+1'],
          showCountryCodes: false
       ),
     ),
 );

Customization

Here is a list of properties available to customize the widget:

Name Type Description
initialPhoneNumber String used to set initial phone number
initialSelection String used to set initial country code
errorText String use this to set an error message
hintText String sets hint
labelText String sets label
errorStyle TextStyle style applied to error message
hintStyle TextStyle style applied to hint
labelStyle TextStyle style applied to label
errorMaxLines int the maximum number of lines user can type
enabledCountries List the list of enabled countries to display
decoration InputDecoration decoration applied to the TextField widget
showCountryCodes bool shows the country code (default true)
showCountryFlags bool shows. the country flags (default true)
dropdownIcon Widget use this to customize dropdown icon

Contributions

Contributions of any kind are more than welcome! Feel free to fork and improve international_phone_input in any way you want, make a pull request, or open an issue.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package