Intl Phone Number Input

A simple and customizable flutter package for international phone number input

What's new

* Improved loading time for country list
* Added support for RTL languages to be presented in the correct alignment
* Added new selector mode dropdown, bottom sheet and dialog
* Added ignoreBlank boolean to avoid input error message when left blank
* As You Type Formatter: The Package now formats the input to it's selected national format
* You can create a PhoneNumber object from PhoneNumber.getRegionInfoFromPhoneNumber(String phoneNumber, [String isoCode]); 
* You can now parse phoneNumber by calling   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

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

Usage

Constructors

s/nConstructor
1InternationalPhoneNumberInput
2InternationalPhoneNumberInput.withCustomDecoration
3InternationalPhoneNumberInput.withCustomBorder

Available Parameters

InternationalPhoneNumberInput({
    Key key,
    @required this.onInputChanged,
    this.onInputValidated,
    this.focusNode,
    this.textFieldController,
    this.onSubmit,
    this.keyboardAction,
    this.countries,
    this.textStyle,
    this.inputBorder,
    this.inputDecoration,
    this.initialCountry2LetterCode = 'NG',
    this.hintText = 'Phone Number',
    this.autoValidate = false,
    this.formatInput = true,
    this.errorMessage = 'Invalid phone number',
    this.selectorType,
    this.ignoreBlank = false,
    this.locale,
    });
ParameterDatatypeInitial ValueDefault 1Decoration 2CustomBorder 3
onInputChangefunction(PhoneNumber)null:heavy_check_mark::heavy_check_mark::heavy_check_mark:
onInputValidatedfunction(string)null:heavy_check_mark::heavy_check_mark::heavy_check_mark:
focusNodeFocusNodenull:heavy_check_mark::heavy_check_mark::heavy_check_mark:
textFieldControllerTextEditingControllerTextEditingController():heavy_check_mark::heavy_check_mark::heavy_check_mark:
onSubmitFunction()null:heavy_check_mark::heavy_check_mark::heavy_check_mark:
keyboardActionTextInputActionnull:heavy_check_mark::heavy_check_mark::heavy_check_mark:
countriesListnull:heavy_check_mark::heavy_check_mark::heavy_check_mark:
textStyleTextStylenull:heavy_check_mark::heavy_check_mark::heavy_check_mark:
inputBorderInputBordernull:heavy_check_mark::x::heavy_check_mark:
inputDecorationInputDecorationnull:heavy_check_mark::heavy_check_mark::x:
initialCountry2LetterCodeStringNG:heavy_check_mark::heavy_check_mark::heavy_check_mark:
hintTextStringPhone Number:heavy_check_mark::x::heavy_check_mark:
autoValidatebooleantrue:heavy_check_mark::heavy_check_mark::heavy_check_mark:
formatInputbooleantrue:heavy_check_mark::heavy_check_mark::heavy_check_mark:
errorMessageStringInvalid phone number:heavy_check_mark::x::heavy_check_mark:
selectorTypePhoneInputSelectorTypenull:heavy_check_mark::heavy_check_mark::heavy_check_mark:
ignoreBlankbooleanfalse:heavy_check_mark::heavy_check_mark::heavy_check_mark:
localeStringnull:heavy_check_mark::heavy_check_mark::heavy_check_mark:

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.

Dependencies

Credits

A special thanks to niinyarko

Libraries

intl_phone_number_input