A simple and customizable flutter package for inputting phone number in intl / international format

Overview

Intl Phone Number Input

A simple and customizable flutter package for inputting phone number in intl / international format uses Google's libphonenumber

CustomDecoration CustomBorder Default
Screenshot_1587652933 Screenshot_1587652933 Screenshot_1587652933
Web

What's new

  • Added support for Flutter Web 🔥 🔥 🔥 🚀 🚀 🚀 .
  • Added textAlign, textAlignVertical.
  • Fixed French translation of Egypt.
  • Added option to make selector button a prefix icon in SelectorConfig.
  • Added cursorColor option.
  • Added scrollPadding option.
  • Added new language translations for Serbia, with two scripts.
  • Updated onSaved into ValueChange<PhoneNumber>. now onSaved returns a PhoneNumber object.
  • Added keyboardType option and improvements on iOS keyboard, see #147, #148 for more details.
  • Added locale zh-TW.
  • Added support of nb and nn locale.
  • Fixed issue with AsYouType formatter injecting country dial code on every input for phone numbers with North American Numbering Plan.
  • Fixed issue with Selector Button onTap when enable is false.
  • Breaking Change for v0.7.0, SelectorConfig.backgroundColor would be removed and replaced with Theme.of(context).canvasColor.
  • Added spaceBetweenSelectorAndTextField for padding between selector button and text field.
  • Fixed Bug with cursor position on typing, see #130 for illustration and more information.
  • Fixed Bug with selector button country restoring to initialValue after updating/changing value, see #155 for more information.
  • Tap outside selectorType PhoneInputSelectorType.BOTTOM_SHEET now dismisses the dialog.

Features

  • Web support.
  • Support for RTL languages
  • Selector mode dropdown, bottom sheet and dialog
  • As You Type Formatter: formats inputs to its selected international format
  • Get Region Info with PhoneNumber.getRegionInfoFromPhoneNumber(String phoneNumber, [String isoCode]);
  • Format PhoneNumber with PhoneNumber.getParsableNumber(String phoneNumber, String isoCode) or PhoneNumber Reference.parseNumber()
  • Custom list of countries e.g. ['NG', 'GH', 'BJ' 'TG', 'CI']
    String phoneNumber =  '+234 500 500 5005';
    PhoneNumber number = await PhoneNumber.getRegionInfoFromPhoneNumber(phoneNumber);
    String parsableNumber = number.parseNumber();
    `controller reference`.text = parsableNumber

Web Support

In your app directory, edit web/index.html to add the following

<!DOCTYPE html>
<html>
    <head>
        ...
    </head>
    <body>
    
        ...

        <script src="packages/libphonenumber_plugin/js/libphonenumber.js"></script>
        <script src="packages/libphonenumber_plugin/js/stringbuffer.js"></script>

        ...

        <script src="main.dart.js" type="application/javascript"></script>
    </body>
</html>

Or checkout /example folder from Github.

Note

    PhoneNumber.getRegionInfoFromPhoneNumber(String phoneNumber, [String isoCode])

Could throw an Exception if the phoneNumber isn't recognised its a good pattern to pass the country's isoCode or have '+' at the beginning of the string

isoCode could be null if PhoneNumber is not recognised

Usage

Constructors

s/n Constructor
1 InternationalPhoneNumberInput

Available Parameters

InternationalPhoneNumberInput({
    Key key,
      this.selectorConfig = const SelectorConfig(),
      @required this.onInputChanged,
      this.onInputValidated,
      this.onSubmit,
      this.onFieldSubmitted,
      this.validator,
      this.onSaved,
      this.textFieldController,
      this.keyboardAction,
      this.keyboardType = TextInputType.phone,
      this.initialValue,
      this.hintText = 'Phone number',
      this.errorMessage = 'Invalid phone number',
      this.selectorButtonOnErrorPadding = 24,
      this.spaceBetweenSelectorAndTextField = 12,
      this.maxLength = 15,
      this.isEnabled = true,
      this.formatInput = true,
      this.autoFocus = false,
      this.autoFocusSearch = false,
      this.autoValidateMode = AutovalidateMode.disabled,
      this.ignoreBlank = false,
      this.countrySelectorScrollControlled = true,
      this.locale,
      this.textStyle,
      this.selectorTextStyle,
      this.inputBorder,
      this.inputDecoration,
      this.searchBoxDecoration,
      this.textAlign = TextAlign.start,
      this.textAlignVertical = TextAlignVertical.center,
      this.scrollPadding = const EdgeInsets.all(20.0),
      this.focusNode,
      this.cursorColor,
      this.autofillHints,
      this.countries
    });
```|

```dart
SelectorConfig({
    this.selectorType = PhoneInputSelectorType.DROPDOWN,
    this.showFlags = true,
    this.useEmoji = false,
    this.backgroundColor,
    this.countryComparator,
    this.setSelectorButtonAsPrefixIcon = false,
});
Parameter Datatype Initial Value
onInputChanged function(PhoneNumber) null
onSaved function(PhoneNumber) null
onInputValidated function(bool) null
focusNode FocusNode null
textFieldController TextEditingController TextEditingController()
onSubmit Function() null
keyboardAction TextInputAction null
keyboardType TextInputType TextInputType.phone
countries List null
textStyle TextStyle null
selectorTextStyle TextStyle null
inputBorder InputBorder null
inputDecoration InputDecoration null
initialValue PhoneNumber null
hintText String Phone Number
selectorButtonOnErrorPadding double 24
spaceBetweenSelectorAndTextField double 12
maxLength integer 15
isEnabled boolean true
autoFocus boolean false
autoValidateMode AutoValidateMode AutoValidateMode.disabled
formatInput boolean true
errorMessage String Invalid phone number
selectorConfig SelectorConfig SelectorConfig()
ignoreBlank boolean false
locale String null
searchBoxDecoration InputDecoration null
textAlign TextAlign TextAlign.start
textAlignVertical TextAlignVertical TextAlignVertical.center
scrollPadding EdgeInsets EdgeInsets.all(20.0)
countrySelectorScrollControlled boolean true
cursorColor String \ null
autofillHints Iterable null

Selector Types

DROPDOWN BOTTOMSHEET DIALOG
Screenshot_1587652933 Screenshot_1587652933 Screenshot_1587652933

Testing

Widget Key parameters and Helper classes are now available for integration testing check out this example 🎯 Integration Testing Example

Contributions

If you encounter any problem or the library is missing a feature feel free to open an issue. Feel free to fork, improve the package and make pull request.

Contributors

Made with contributors-img.

Dependencies

Credits

A special thanks to niinyarko

FAQ

  • For discussions and frequent question and concerns, check here
You might also like...

An App I made to learn of FIrebase Phone Auth and ML Kit

demoapp A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Oct 19, 2021

Android app to show movie ratings when browsing Netflix, Amazon Prime Video and other supported video streaming apps on the phone

Android app to show movie ratings when browsing Netflix, Amazon Prime Video and other supported video streaming apps on the phone

Flutter - Movie Ratings You can get the latest Playstore version here on Playstore - or download directly - 0.4.5 Screenshots of master Search Page Fa

Nov 23, 2022

A starter helper for flutter developers wanting to use firebase phone authentication in their app.

riverpod_firebase_phone_auth A new Flutter project template showing how to handle mobile authentication using Firebase and Riverpod. Packages Used Fre

Oct 31, 2022

WebRTC Phone based on MQTT, Flutter

WebRTC Phone based on MQTT, Flutter

Flutter WebRTC Phone Using a MQTT client and a Flutter, an example source of WebRTC bidirectional video communication. WebRTC WebRTC를 이용한 화상/데이터 통신은 기

Oct 31, 2022

Flutter-video-player - A basic file manager based video player app where you can watch videos from your phone's file manager

Flutter-video-player - A basic file manager based video player app where you can watch videos from your phone's file manager

Flutter video player app It's a file manager based video player app. Screenshot

Jan 25, 2022

The Quack Project on every Emory student phone, organizing the calendars of users & eliminating all frustrations with on-campus dining.

Bestagons Micro-Charter Code Name: Quack Mission Statement: Bestagons are a 6-person team dedicated to developing the experience and skills necessary

Dec 20, 2021

App to seamlessly share files/images from your phone to your pc

App to seamlessly share files/images from your phone to your pc

Self-Share App to seamlessly share files/images from your phone to your pc Image

May 28, 2022

The most complete Chat UI for flutter highly customizable and helps developing chat UI faster.

⚠️ Dashchat v2 is available in v2 branch ⚠️ You can open issues for the v2 to indicate things we need to implement/fix. Also the API can change until

Dec 11, 2022

Fully customizable neumorphic containers for your flutter projects.

Fully customizable neumorphic containers for your flutter projects.

neumorphic_container Fully customisable Neumorphic Containers for your flutter projects. Getting Started In the pubspec.yaml of your flutter project,

Jul 13, 2022
Owner
null
Expenses tracker built with Flutter and Dart making use of Provider, Intl, Syncfusion Flutter Datepicker and more

expense_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Atuoha Anthony 2 Dec 10, 2022
The Flutter Firebase Phone Auth application for authenticating the user's mobile phone

Flutter Firebase Phone Auth ✨ About The Flutter Firebase Phone Auth application

Dileepa Bandara 3 Aug 25, 2022
News Adda is a news app that selects the latest and best news from multiple national and international sources

News Adda A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

 Geeky.dev 7 Apr 22, 2022
The FlexGrid control provides a powerful and quickly way to display data in a tabular format. It is including that frozened column/row,loading more, high performance and better experience in TabBarView/PageView.

flex_grid Language: English| 中文简体 The FlexGrid control provides a powerful and quickly way to display data in a tabular format. It is including that f

FlutterCandies 39 Nov 8, 2022
Slibro is a full-fledged story writing and publishing platform that supports short and long format stories

Slibro is a full-fledged story writing and publishing platform that supports short and long format stories. Flutter, Appwrite, and Rapyd is use

Souvik Biswas 7 Dec 8, 2022
Number trivia Android and ios application using flutter clean architecture

demo_project A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Koushik J A 2 Jun 9, 2022
An app which shows the total number of covid cases, recovered, etc. As well as of particular country too.

covid_app Images of Project A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get

Priyam Soni 0 Oct 18, 2021
This app developed for making fun with sms. You can send huge sms to other's number by one click. It is behaving like a bomb

SMS Bomber This app developed for making fun with sms. You can send huge sms to other's number by one click. It is behaving like a bomb Getting Starte

Md Abir Ahsan Tahmim 1 Dec 21, 2021
Whats-link - App to open conversation without having to save the number in WhatsApp

Whats Link App feito para abrir conversa do WhtasApp sem salvar o número do dest

Eduardo Alonso 1 Feb 14, 2022
A beautiful and cross platform NHentai Client, Support desktop and mobile phone

A beautiful and cross platform NHentai Client. Support desktop and mobile phone (Mac/Windows/Linux/Android/IOS).

null 324 Dec 29, 2022