intl_phone_number_input 0.4.1

Flutter Android iOS

A simple and customizable flutter package on International Phone Number Input.

Intl Phone Number Input #

A simple and customizable flutter package for international phone number input

CustomDecorationCustomBorderDefault
Screenshot_1587652933Screenshot_1587652933Screenshot_1587652933

What's new #

* Added selectorTextStyle parameter
* Improve load up time
* Added new initialValue parameter that accepts a PhoneNumber object
* Added autoFocus option
* Added support for integration testing
* Added Keys and Helper class for testing
* Updated static method getParsableNumber from PhoneNumber

Features #

* 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

Note #

   onInputChanged(PhoneNumber value) {
      setState((){});
   }

❓ Calling setState inside onInputChanged and onInputValidated causes the Widget to rebuild multiple times and soft keyboard hidding after textfield is focused. Not fix is available yet I'm opened to suggestions and PRs on this issue

    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/nConstructor
1InternationalPhoneNumberInput
2InternationalPhoneNumberInput.withCustomDecoration
3InternationalPhoneNumberInput.withCustomBorder

Available Parameters #

InternationalPhoneNumberInput({
    Key key,
    this.selectorType,
    @required this.onInputChanged,
    this.onInputValidated,
    this.focusNode,
    this.textFieldController,
    this.onSubmit,
    this.keyboardAction,
    this.countries,
    this.textStyle,
    this.selectorTextStyle,
    this.inputBorder,
    this.inputDecoration,
    this.searchBoxDecoration,
    this.initialValue,
    this.hintText = 'Phone Number',
    this.isEnabled = true,
    this.autoFocus = false,
    this.autoValidate = false,
    this.formatInput = true,
    this.errorMessage = 'Invalid phone number',
    this.ignoreBlank = false,
    this.locale,
    this.countrySelectorScrollControlled = true,
    });
ParameterDatatypeInitial ValueDefault [1]Decoration [2]CustomBorder [3]
onInputChangedfunction(PhoneNumber)null✔️✔️✔️
onInputValidatedfunction(bool)null✔️✔️✔️
focusNodeFocusNodenull✔️✔️✔️
textFieldControllerTextEditingControllerTextEditingController()✔️✔️✔️
onSubmitFunction()null✔️✔️✔️
keyboardActionTextInputActionnull✔️✔️✔️
countriesListnull✔️✔️✔️
textStyleTextStylenull✔️✔️✔️
selectorTextStyleTextStylenull✔️✔️✔️
inputBorderInputBordernull✔️✔️
inputDecorationInputDecorationnull✔️✔️
initialValuePhoneNumbernull✔️✔️✔️
hintTextStringPhone Number✔️✔️
isEnabledbooleantrue✔️✔️✔️
autoFocusbooleanfalse✔️✔️✔️
autoValidatebooleanfalse✔️✔️✔️
formatInputbooleantrue✔️✔️✔️
errorMessageStringInvalid phone number✔️✔️
selectorTypePhoneInputSelectorTypePhoneInputSelectorType.DROPDOWN✔️✔️✔️
ignoreBlankbooleanfalse✔️✔️✔️
localeStringnull✔️✔️✔️
searchBoxDecorationInputDecorationnull✔️✔️
countrySelectorScrollControlledbooleantrue✔️✔️✔️

Selector Types #

DROPDOWNBOTTOMSHEETDIALOG
Screenshot_1587652933Screenshot_1587652933Screenshot_1587652933

Testing #

Widget Key parameters and Helper classe 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.

Dependencies #

Credits #

A special thanks to niinyarko

102
likes
80
pub points
95%
popularity

A simple and customizable flutter package on International Phone Number Input.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

ogunye4nao@gmail.com

License

MIT (LICENSE)

Dependencies

equatable, flutter, libphonenumber, provider

More

Packages that depend on intl_phone_number_input