fromNational static method

  1. @internal
PhoneNumber fromNational(
  1. String isoCode,
  2. String national
)

parses a national phone number given an iso code

The difference with fromIsoCode is that here we assume that the phoneNumber is a national one. Therefor some parsing steps are skipped.

This is useful for when you know in advance that a phone number is a national version. For example in a phone number input with two inputs for the country code and national number

Implementation

@internal
static PhoneNumber fromNational(String isoCode, String national) {
  isoCode = IsoCodeParser.normalizeIsoCode(isoCode);
  national = TextParser.normalize(national);
  final result = _parse(isoCode, national);
  // we only want to modify the national number when it is valid
  if (result.validate()) return result;
  return PhoneNumber(isoCode: isoCode, nsn: national);
}