isPossibleNumberString method
Check whether a phone number is a possible number given a number in the form of a string, and the region where the number could be dialed from. It provides a more lenient check than isValidNumber. See isPossibleNumber for details.
This method first parses the number, then invokes [isPossibleNumber] with the resultant PhoneNumber object.
number
the number that needs to be checked, in the form of a string.
regionDialingFrom
the region that we are expecting the number to be dialed from.
Note this is different from the region where the number belongs.
For example, the number +1 650 253 0000 is a number that belongs to US.
When written in this form, it can be dialed from any region. When it is
written as 00 1 650 253 0000, it can be dialed from any region which uses
an international dialling prefix of 00. When it is written as
650 253 0000, it can only be dialed from within the US, and when written
as 253 0000, it can only be dialed from within a smaller area in the US
(Mountain View, CA, to be more specific).
returns true if the number is possible.
Implementation
bool isPossibleNumberString(String number, String regionDialingFrom) {
try {
return isPossibleNumber(parse(number, regionDialingFrom));
} catch (e) {
return false;
}
}