Giter VIP home page Giter VIP logo

intl-phone-number-input's Introduction

Intl Phone Number Input

A simple and customizable flutter package for international phone number input

What's new

* onInputChanged now returns a new PhoneNumber Model
* 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/n Constructor
1 InternationalPhoneNumberInput
2 InternationalPhoneNumberInput.withCustomDecoration
3 InternationalPhoneNumberInput.withCustomBorder

Available Parameters

InternationalPhoneNumberInput({
    @required this.onInputChanged,
    this.onInputValidated,
    this.focusNode,
    this.textFieldController,
    this.onSubmit,
    this.keyboardAction,
    this.countries,
    this.inputBorder,
    this.inputDecoration,
    this.initialCountry2LetterCode = 'NG',
    this.hintText = '(800) 000-0001 23',
    this.shouldParse = true,
    this.shouldValidate = true,
    this.formatInput = true,
    this.errorMessage = 'Invalid phone number',
    });
Parameter Datatype Initial Value Default [1] Decoration [2] CustomBorder [3]
onInputChange function(PhoneNumber) null ✔️ ✔️ ✔️
onInputValidated function(string) null ✔️ ✔️ ✔️
focusNode FocusNode null ✔️ ✔️ ✔️
textFieldController TextEditingController TextEditingController() ✔️ ✔️ ✔️
onSubmit Function() null ✔️ ✔️ ✔️
keyboardAction TextInputAction null ✔️ ✔️ ✔️
countries List null ✔️ ✔️ ✔️
inputBorder InputBorder null ✔️ ✔️
inputDecoration InputDecoration null ✔️ ✔️
initialCountry2LetterCode String NG ✔️ ✔️ ✔️
hintText String (800) 000-0001 23 ✔️ ✔️
shouldParse boolean true ✔️ ✔️ ✔️
shouldValidate boolean true ✔️ ✔️ ✔️
formatInput boolean true ✔️ ✔️ ✔️
errorMessage String Invalid phone number ✔️ ✔️

Examples

InternationalPhoneNumberInput(
 onInputChanged: onPhoneNumberChanged,
);

Media 1|100x200,20%

InternationalPhoneNumberInput(
  onInputChanged: onPhoneNumberChanged,
  shouldParse: false,
  );

Media 2

InternationalPhoneNumberInput(
  onInputChanged: onPhoneNumberChanged,
  shouldParse: true,
  shouldValidate: true,
  initialCountry2LetterCode: 'US',
  hintText: 'Insert phone number',
  );

Media 3

InternationalPhoneNumberInput.withCustomBorder(
  onInputChanged: onPhoneNumberChanged,
  inputBorder: OutlineInputBorder(),
  hintText: '(100) 123-4567 8901',
  initialCountry2LetterCode: 'US',
  errorMessage: 'Wrong number',
);

Media 4

InternationalPhoneNumberInput.withCustomDecoration(
  onInputChanged: onPhoneNumberChanged,
  initialCountry2LetterCode: 'US',
  inputDecoration: InputDecoration(
    border: OutlineInputBorder(
    borderRadius: BorderRadius.all(
      Radius.circular(40),
      ),
    ),
  ),
);

Media 4

InternationalPhoneNumberInput.withCustomDecoration(
  onInputChanged: onPhoneNumberChanged,
  onInputValidated: onInputChanged,
  initialCountry2LetterCode: 'US',
  inputDecoration: InputDecoration(
    hintText: 'Enter phone number',
    errorText: valid ? null : 'Invalid',
    border: OutlineInputBorder(
      borderRadius: BorderRadius.all(
        Radius.circular(40),
      ),
    ),
  ),
);

Media 6

Dependencies

Credits

A special thanks to niinyarko

intl-phone-number-input's People

Contributors

app17 avatar eboye avatar natintosh avatar sharpred avatar

Watchers

 avatar

Forkers

sharpred

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.