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

Default GB masks differ #64

Open
NiallBunting opened this issue Mar 25, 2024 · 0 comments
Open

Default GB masks differ #64

NiallBunting opened this issue Mar 25, 2024 · 0 comments

Comments

@NiallBunting
Copy link

On a flutter iOS app I'm running into issues after someone changes from the default option (UK) and then back to it, the uk mask is inconsistent.

I have two text boxes with the following [+44] [rest of number]. And the following formatter:

LibPhonenumberTextFormatter(
    phoneNumberType: PhoneNumberType.mobile,
    phoneNumberFormat: PhoneNumberFormat.national,
    country: _currentlySelectedCountry,
    inputContainsCountryCode: false)

This will work fine for the first number. If I then change it from GB -> US -> GB using the country drop down if I type in a number you will only be able to type in half. I.e the formatter allows only "0 000000".

If I change inputContainsCountryCode to true. Then the default GB requires you to enter the country code in the second box and the country GB doesn't.

The issue seem to stem from the fact that phoneMaskMobileNational is different between the two responses. This means that the LibPhonenumberTextFormatter can't work in a consistent way between the two options.

LibPhonenumberTextFormatter(
phoneNumberType: PhoneNumberType.mobile,
phoneNumberFormat: PhoneNumberFormat.national,
country: _currentlySelectedCountry,
inputContainsCountryCode: true,

CountryWithPhoneCode.gb() gives the following:

CountryWithPhoneCode(countryName: United Kingdom, regionCode: GB, phoneCode: 44, exampleNumberMobileNational: 07400 123456, exampleNumberFixedLineNational: 0121 234 5678, phoneMaskMobileNational: 00000 000000, phoneMaskFixedLineNational: 0000 000 0000, exampleNumberMobileInternational: +44 7400 123456, exampleNumberFixedLineInternational: +44 121 234 5678, phoneMaskMobileInternational: +00 0000 000000, phoneMaskFixedLineInternational: +00 000 000 0000)

From the countries list I get this:

CountryWithPhoneCode(countryName: United Kingdom, regionCode: GB, phoneCode: 44, exampleNumberMobileNational: 07400 123456, exampleNumberFixedLineNational: 0121 234 5678, phoneMaskMobileNational: +00 00000 000000, phoneMaskFixedLineNational: +00 0000 000 0000, exampleNumberMobileInternational: +44 7400 123456, exampleNumberFixedLineInternational: +44 121 234 5678, phoneMaskMobileInternational: +00 0000 000000, phoneMaskFixedLineInternational: +00 000 000 0000)
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

1 participant