Phone Numbers Parser
Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios.
The advantage of this lib instead of libphonenumber is that it instantly supports all platforms (no need for channeling).
Features
- Find phone numbers in a text
- Validate a phone number
- Find the region of a phone number
- Phone number parsing
- A light parser for size aware applications
- Supports easthern arabic digits
- Uses best-in-class metadata from Google's libPhoneNumber project.
Parsers
There are two parsers: LightPhoneParser and Phone Parser
LightPhoneParser:
- smaller size footprint (more will be tree shaken)
- uses mainly length information for validation
- fast
PhoneParser:
- more accurate
- more utilities
- bigger size footprint
- more computationally intensive
- uses pattern matching
Usage PhoneParser
Usage LightPhoneParser
Migration to 1.0.0
1.0.0 introduces two parsers:
- PhoneParser: Heavy, more accurate and more computationally intensive (relies on pattern matching)
- LightPhoneParser: Light, somewhat accurate and less computationally intensive (relies on length)
If a light validation based on length suffice, LightPhoneParser can be used, assuming you don't import
the other parser, that will decrease the library size footprint.
With this change a few breaking changes had to be made
before:
after:
Demo
The phone number input packages has a demo that uses this parser: https://cedvdb.github.io/phone_form_field/