-
Notifications
You must be signed in to change notification settings - Fork 521
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
Get ISO2Code from phone number string #372
base: develop
Are you sure you want to change the base?
Conversation
Instaed of passing just the prefix, you can pass the whole phone number to extract the ISOCode, this helps in case you just want to know the isocode and then build the PhoneNumber from string
lib/src/utils/phone_number.dart
Outdated
@@ -108,7 +108,7 @@ class PhoneNumber extends Equatable { | |||
if (prefix.isNotEmpty) { | |||
prefix = prefix.startsWith('+') ? prefix : '+$prefix'; | |||
var country = Countries.countryList | |||
.firstWhereOrNull((country) => country['dial_code'] == prefix); | |||
.firstWhereOrNull((country) => prefix.contains(country['dial_code']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing one more bracket at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!, no need more brackets, what are you talking about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at the end of 111
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you are right!
Instaed of passing just the prefix, you can pass the whole phone number to extract the ISOCode, this helps in case you just want to know the isocode and then build the PhoneNumber from string or get the dial code