Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeCountryCodeFromMask results in incorrect phone mask for national numbers #22

Open
woelmer opened this issue Sep 21, 2021 · 2 comments

Comments

@woelmer
Copy link

woelmer commented Sep 21, 2021

Calling this text formatter:

LibPhonenumberTextFormatter( country: usCountry, PhoneNumberFormat.national)

Will result in the following mask "0) 000-0000"
It should be "(000) 000-0000"

There are a couple problems:

  1. input_formatter.dart line 28: removeCountryCodeFromMask gets set to true even though the phone number is a national number and the inputContainsCountryCode is false.

  2. Once removeCountryCodeFromMask is true country_data.dart line 188 will remove three characters from the beginning of the national mask therefore chopping off the area code portion of the national phone number mask.

@woelmer woelmer changed the title removeCountryCodeFromMask results in incorrect phone mask for US and national number removeCountryCodeFromMask results in incorrect phone mask for national numbers Nov 8, 2021
@mockturtl
Copy link

@acoutts This bug is still present in 2.1.5.

In my use case, the "country picker" is a separate dropdown / bottom sheet, so the input text field will not include the "pluscode" ("national" format; inputContainsCountryCode is false).

Since the mask is "national" (already excludes the pluscode), I believe it's redundant to trim it by taking a substring.

mockturtl added a commit to mockturtl/flutter_libphonenumber_platform_interface that referenced this issue Sep 23, 2023
@mockturtl
Copy link

I forked the repo to fix this issue for my use case. Feedback / PR's welcome.

fix-22-national-mask

dependency_overrides:
  flutter_libphonenumber_platform_interface: #https://github.com/acoutts/flutter_libphonenumber/issues/22
    git:
      url: https://github.com/mockturtl/flutter_libphonenumber_platform_interface
      ref: fix-22-national-mask

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants