A customised Flutter TextFormField to input international phone number along with country code.

Overview

International Phone Field Package

Pub

A customised Flutter TextFormField to input international phone number along with country code.

This widget can be used to make customised text field to take phone number input for any country along with an option to choose country code from a dropdown.

Screenshots

Installing

To use this package:

Run this command:

flutter pub add intl_phone_field

Or, add the following to your pubspec.yaml file:

dependencies:
  intl_phone_field: ^3.0.0

How to Use

Simply create a IntlPhoneField widget, and pass the required params:

IntlPhoneField(
    decoration: InputDecoration(
        labelText: 'Phone Number',
        border: OutlineInputBorder(
            borderSide: BorderSide(),
        ),
    ),
    initialCountryCode: 'IN',
    onChanged: (phone) {
        print(phone.completeNumber);
    },
)

Use initialCountryCode to set an initial Country Code.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Comment on Issue or Pull Request, asking @all-contributors to add a contributor:

@all-contributors please add @<username> for <contributions>

: See the Emoji Key (Contribution Types Reference) for a list of valid contribution types.

CONTRIBUTORS

LICENSE

License: MIT

Comments
  • #138 Add support for region codes

    #138 Add support for region codes

    See #138 - this PR resolves issue #138.

    We now have support for region codes and when initialising a IntlPhoneField with a full/complete number (consisting of country+region code, it will correctly remove the prefix and only display the actual number in the TextField.

    Added unit tests to verify this functions as required. Examples taken from a UK number vs Guernsey number which both have +44 prefix, but Guernsey is further identified with 1481 as the regionCode. The regionCode for other similar countries/enclaves will need to be updated in countries.dart as required.

    opened by lingster 5
  • BREAKING, Incorrect mobile required length

    BREAKING, Incorrect mobile required length

    After the latest update the widget requires 9 digits for example where a country needs 10 (Egypt) which how it was initially, i also want to remove the x/9 validator but to no avail.

    opened by yassinsameh 5
  • (#12) Correct validation

    (#12) Correct validation

    According to E.164, the maximum length of the "subscriber number" is 12 digits, but may be shorter. Additionally, the validation message made the assumption that a mobile number was being entered.

    opened by zmeggyesi 5
  • [1.2.0] Improvements and more customizations

    [1.2.0] Improvements and more customizations

    • PhoneNumber now has a Country attribute instead of a simple country code. Allows to access the flag and name of the country afterwards.
    • Added support of a target length, by default 10.
    • Added support for a counter
    • Added support for custom formatters
    opened by gaetschwartz 5
  • Fluent_ui support

    Fluent_ui support

    This widget is using TextFormField from the material library. When developing windows applications I use the FluentUI library. So I have an error "no material widget found". Is it possible to use this widget with that library? Or I should create my own one using this widget source code?

    opened by AndriiHarashchak 4
  • Invalid max Length for Indonesian phoneNumber

    Invalid max Length for Indonesian phoneNumber

    I think 10 for Indonesian phoneNumber was invalid, because with country code included there was number with 12 even 13 number length. I appreciate if this can be updated ASAP as I like this package so much. Thanks

    opened by rizkyagungramadhan 4
  • Flag and number don't update according to initial value

    Flag and number don't update according to initial value

    If we provide an initial value or a controller with a text prepopulated, then the flag and number don't update according to the provided value.

    For example if initValue="+33123456789" the flag should be the French one and the displayed number should be "123456789".

    Instead it displays the US flag or whatever is the initialCountryCode and the displayed number remains "+33123456789"

    opened by aris-1 4
  • Validation Logic is faulty

    Validation Logic is faulty

    The Validation logic doesn't check according to the selected country's max length. It compares to constant value 10. Which fails on several country selection validations. Thus auto validation doesn't work. Here is the code from the package.

    validator = widget.autoValidate ? ((value) => value != null && value.length != 10 ? 'Invalid Mobile Number' : null) : widget.validator;

    bug 
    opened by jahid-hasan-polash 4
  • Add ability to specify which countries to show in the dropdown

    Add ability to specify which countries to show in the dropdown

    This is to handle feature requests #43. A valid use case where the app is not available in all countries and the developer wants to restrict the list of countries to only the supported ones.

    With Null safety support.

    opened by 4mitabh 4
  • Replacing argument

    Replacing argument "child" with "builder" in showDialog function due to deprecation

    Replacing argument "child" with "builder" since the "child" argument has recently been deprecated from the showDialog function. This argument was deprecated in v0.2.3.

    Fixes issue number vanshg395/intl_phone_field#31.

    I see that there is another pull request for fixing the same issue, but this pull request minimizes the changes to only fixing this issue.

    opened by bclarksoftware 4
  • Fixes Singapore length

    Fixes Singapore length

    Singapore mobile number length is 8 and not 12 (as currently in the package) reference: https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers#:~:text=XXX)%20YYY%20ZZZZ.-,Singapore,there%20are%20no%20area%20codes.

    opened by KevalPrajapati 3
  • It works only for country like Canada and US, which having country code one digit.

    It works only for country like Canada and US, which having country code one digit.

    If the country code is 2 digits then the max length change to 9 if country code is 3 digits then max length change 8, I use for Australia phone form is (0412345678) which is a 10 digits, but this package accept 9 digits, please fix this,

    opened by ziagit 0
  • Update countries.dart - For Dominican Republic

    Update countries.dart - For Dominican Republic

    Hello, We are like USA and Canada. We have "dialCode" 829 - 809 and 849 + 7 digits like 000-0000. All phones number here are or +1809-000-0000 or +1829-000-0000 or +1849-000-0000

    opened by edner84 0
  • l10n + search by dialCode + custom countries list + improvment

    l10n + search by dialCode + custom countries list + improvment

    This contribution is a fork of #227 with some improvements. The initial PR message can be found at the end.

    Modification

    • add autofillHint with the possibility of disabled it
    • search starting with '+' is treat as search by dialCode (prevent returning empty list of country when user type only "+")
    • fix sorting countries name after search
    • default validator return error if not numeric
    • add sizeBox before dropdown, better visibility and prevent flag to touch border if no dropdown icon
    • update countries argument : After seeing a lot of issues requesting the change of min & max length (#225, #238,...), some PR (#218,#212, ...)and also personally wanted to change the file. I found it will be better changing the format of the argument countries to accept a list of Country instead of list of ISO code. Like this you can still provide a limited list of country but you can also change parameters of the initial country list. In addition after adding l10n, this change is perfect for adding new locales to the file. I think it will reduce the time of maintaining the package and if the package is no longer maintained people can still use it without fork it.

    I hope this PR will help and feel free to ask me modifications or question !

    Initial message

    This contribution contains a set of improvements to the package, It contains:

    • Added a new property to the Country model called nameTranslations, it is a map that has a language code as a key and the localized name that correspond to the language.
    • Contain search results when typing the name in any of the provided translations
    • Fix searching for country code does not work when there's a "+".
    • Use flag emojis instead of png to reduce the package size (Personal opinion).
    • Sort Countries ascending by name ... for all languages
    opened by launay12u 0
  • Fixed data encoding errors and length limitations.

    Fixed data encoding errors and length limitations.

    Signed-off-by: hqber [email protected]

    Taiwan, Hong Kong and Macao belong to China. They are not a country. Data source:https://support.huaweicloud.com/intl/zh-cn/productdesc-msgsms/phone_numbers.html

    opened by hqber 0
A Flutter package provides some implementations of TextInputFormatter that format input with pre-defined patterns

A Flutter package provides some implementations of TextInputFormatter that format input with pre-defined patterns

HungHD 192 Dec 31, 2022
A low code editor with the full power of flutter.

flutter_blossom ?? Low code editor with the full power of flutter. Think in flutter, watch your ideas come to life, plan ahead and let your creativity

Flutter Blossom 0 Dec 2, 2021
Text Editor in Flutter for Android and iOS to help free write WYSIWYG HTML code

Flutter Summernote Text Editor in Flutter for Android and iOS to help free write WYSIWYG HTML code based on Summernote 0.8.18 javascript wrapper. NOTI

Chandra Abdul Fattah 41 Sep 12, 2022
A customizable code text field supporting syntax highlighting

CodeField A customizable code text field supporting syntax highlighting Live demo A live demo showcasing a few language / themes combinaisons Showcase

Bertrand 162 Dec 23, 2022
Flutter textfield validation lets you validate different textform fields in your Flutter app

Flutter textfield validation lets you validate different textform fields in your Flutter app

World-Package 2 Sep 15, 2022
A markdown renderer for Flutter.

Flutter Markdown A markdown renderer for Flutter. It supports the original format, but no inline HTML. Overview The flutter_markdown package renders M

Flutter 828 Aug 12, 2021
A masked text for Flutter.

flutter_masked_text Masked text input for flutter. Alert Hi guys! Unfortunately, I'm not developing mobile anymore. This repo will not receive updates

Ben-hur Santos Ott 264 Dec 21, 2022
Soft and gentle rich text editing for Flutter applications.

About Zefyr Soft and gentle rich text editing for Flutter applications. You are viewing early dev preview version of this package which is no longer a

Memspace 2.2k Jan 8, 2023
Flutter widget that automatically resizes text to fit perfectly within its bounds.

Flutter widget that automatically resizes text to fit perfectly within its bounds. Show some ❤️ and star the repo to support the project Resources: Do

Simon Leier 1.8k Jan 3, 2023
A Flutter package to parse text and make them into linkified text widget

?? Flutter Parsed text A Flutter package to parse text and extract parts using predefined types like url, phone and email and also supports Regex. Usa

Fayeed Pawaskar 213 Dec 27, 2022
A Flutter Package to render Mathematics, Physics and Chemistry Equations based on LaTeX

flutter_tex Contents About Demo Video Screenshots How to use? Android iOS Web Examples Quick Example TeXView Document TeXView Markdown TeXView Quiz Te

Shahzad Akram 219 Jan 5, 2023
flutter 中文排版,支持分页上下对齐 两端对齐 翻页动画

text_composition flutter 中文排版 分页 上下对齐 两端对齐 多栏布局 弃用richText,使用Canvas,精确定位绘图位置,消除字体对排版影响 视频与截图 demo https://github.com/mabDc/text_composition/releases/t

西红柿大芝麻 50 Nov 3, 2022
Flutter Tutorial - PDF Viewer - Asset, File, Network & Firebase

Flutter Tutorial - PDF Viewer - Asset, File, Network & Firebase Use the Flutter PDF Viewer to download PDF documents and display them within your Flut

Johannes Milke 36 Dec 9, 2022
Create an AutoComplete TextField to search JSON data based on suggestions in Flutter.

Flutter Tutorial - AutoComplete TextField & AutoComplete Search Create an AutoComplete TextField to search JSON data based on suggestions in Flutter.

Johannes Milke 32 Oct 23, 2022
A simple Flutter package that makes turning a FAB into a text field easy.

flutter_text_field_fab A simple Flutter widget that makes turning a FAB into a text field easy.

Haefele Software 4 Jan 18, 2022
Soft and gentle rich text editing for Flutter applications

Soft and gentle rich text editing for Flutter applications. Zefyrka is a fork of Zefyr package with the following improvements: support Flutter 2.0 op

null 85 Dec 21, 2022
Rich Text renderer that parses Contentful Rich Text JSON object and returns a renderable Flutter widget

Contentful Rich Text Renderer for Flutter Rich Text renderer that parses Contentful Rich Text field JSON output and produces a Flutter Widget tree tha

Kumanu 45 Nov 10, 2022
Flutter App for beginner

i_am_rich 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

Trần Văn Nguyên 1 Nov 17, 2021
A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.

Extended official text to build special text like inline image or @somebody quickly,it also support custom background,custom over flow and custom selection toolbar and handles.

FlutterCandies 509 Jan 4, 2023