phone_numbers_parser 0.1.3 copy "phone_numbers_parser: ^0.1.3" to clipboard
phone_numbers_parser: ^0.1.3 copied to clipboard

outdated

Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios.

example/lib/main.dart

import 'package:phone_numbers_parser/phone_numbers_parser.dart';

void main(List<String> arguments) {
// creation
  final frPhone = PhoneNumber.fromRaw('+33 655 5705 76');
  final frPhone1 = PhoneNumber.fromIsoCode('fr', '655 5705 76');
  final frPhone2 = PhoneNumber.fromDialCode('33', '655 5705 76');
  final frPhone3 = PhoneNumber.fromIsoCode('fr', '0655 5705 76');
  final international = '+33655570576';
  final allInternationalEqual = international == frPhone.international &&
      international == frPhone1.international &&
      international == frPhone2.international &&
      international == frPhone3.international;
  print(allInternationalEqual); // true

// extracting info
  print(frPhone.dialCode); // 33
  print(frPhone.isoCode); // fr
  print(frPhone.validate(PhoneNumberType.fixedLine)); // false
  print(frPhone.validate(PhoneNumberType.mobile)); // true
  print(frPhone.validate(null)); // true

// changing the country
  final esPhone = frPhone.copyWithIsoCode('ES');
  print(esPhone.dialCode); // 34
  print(esPhone.isoCode); // ES
  print(esPhone.international); // '+34655570576'

// utils
  final text = 'hey my phone number is: +33 939 876 218';
  final found = PhoneNumberUtil.findPotentialPhoneNumbers(text);
  print(text.substring(found.first.start, found.first.end));
// country list for display
  final allCountries =
      countries; // contains name, isoCode, dialCode, leading digits, etc
  print(allCountries.length);
}
151
likes
0
pub points
98%
popularity

Publisher

unverified uploader

Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on phone_numbers_parser