Open Hwan-seok opened 3 years ago
I ran into the same issue for +1000002405
Same issue here
I ran into the same issue for +123456789
Same issue with latest version (0.7.1)
Bumping this
Still face this issue on the latest version (0.7.1)
Found another one: +1 945-894-9194
.
What's worse is that Android allows this phone number but iOS crashes.
This is what I am doing as a temporary fix for now:
Using phone_number, I validate the phone number before initializing intl_phone_number_input.
import 'package:phone_number/phone_number.dart' as PhoneNumberValidator;
...
PhoneNumberValidator.PhoneNumber validatedPhoneNumber =
await PhoneNumberValidator.PhoneNumberUtil()
.parse("+1 945-894-9194");
phoneNumber = PhoneNumber(
phoneNumber: validatedPhoneNumber.nationalNumber,
dialCode: validatedPhoneNumber.countryCode,
isoCode: validatedPhoneNumber.regionCode);
@natintosh can you fix the issue, please?
This is a regression. The problem is in the libphonenumber_plugin
Here:
func getRegionInfo(call: FlutterMethodCall, result: @escaping FlutterResult) {
let arguments = call.arguments as! Dictionary<String, Any>
let phoneNumber = arguments["phoneNumber"] as! String
let isoCode = arguments["isoCode"] as! String //<<< HERE the bug #1
do {
let p: PhoneNumber = try phoneNumberKit.parse(phoneNumber, withRegion: isoCode.uppercased(), ignoreType: true)
let regionCode: String? = phoneNumberKit.getRegionCode(of: p)
let countryCode: String? = phoneNumberKit.mainCountry(forCode: p.countryCode) //<<< HERE the bug #2
let formattedNumber: String? = phoneNumberKit.format(p, toType: PhoneNumberFormat.national)
let data : Dictionary<String, String?> = ["isoCode": regionCode, "regionCode" : countryCode, "formattedPhoneNumber" : formattedNumber]
result(data)
The fix of the bug #1:
var isoCode = arguments["isoCode"] as! String
if (isoCode.isEmpty) {
isoCode = PhoneNumberKit.defaultRegionCode()
}
This will fix this issue.
The fix of the bug #2:
let countryCode: String = String(p.countryCode)
This will fix an issue with formatting of the input number. Now if you input the number, it contains digital country code (like +1
), but it should not contain.
Oh, I see that it's already fixed in the libphonenumber_plugin: 0.3.1
, so @natintosh could you just update the dependency, please.
Describe the bug The application crashes when calling PhoneNumber.getRegionInfoFromPhoneNumber Sorry because I cannot reproduce it but the firebase crash report says as follows.
Package version
0.7.0+2
Flutter version
2.5.3
To Reproduce call
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Targeted platforms (please complete the following information):
Additional context This is the crash report