Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

PhoneNumber().parse always returns first matching country for countries having same dial code number in Android. iOS working as expected. #118

Open
2 of 7 tasks
WaseemAbbasi22 opened this issue Jan 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@WaseemAbbasi22
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

2.0.1

Platforms

  • Android
  • iOS
  • Linux
  • MacOS
  • Web
  • Windows

Flutter doctor

[✓] Flutter (Channel stable, 3.10.4, on macOS 13.2.1 22D68 darwin-x64, locale en-GB))
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.78.2)
[✓] Connected device (1 available)
[✓] Network resources

Minimal code example

try {
PhoneNumber phoneNumber = await PhoneNumberUtil().parse("+16045551234" );
print('result phone i got is ${resultPhone.regionCode}');
print('result phone2 i got is ${resultPhone.e164}');
} catch (e) {
print('exception i got is $e');
return null;
}

Current Behavior

await plugin.parse("+16045551234" ); always returns US as country it's same with other countries as well having the same country code i read the previous issues it's stated that it's fixed but still have the same issue on andriod

Expected Behavior

await PhoneNumberUtil().parse("+16045551234" ); should returns CA

Steps To Reproduce

Try parsing +16045551234 on Android only. Ios works as expected

Aditional information

This fix is only need for Android. For iOS it is working properly.

Previously Region Code was parsed using getRegionCodeForCountryCode() function but the country code for US and Canada is same '+1' so it always returned 'US'.

In updated code it uses getRegionCodeForNumber() function that gives accurate Region code which considers whole phone number. So it returns right Region code. this is the prevous issue fixes but it's still have the same problem in latest version

@WaseemAbbasi22 WaseemAbbasi22 added the bug Something isn't working label Jan 12, 2024
@WaseemAbbasi22 WaseemAbbasi22 changed the title [Field name or General]: <title> PhoneNumber().parse always returns first matching country for countries having same dial code number in Android. iOS working as expected. Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant