getNationalSignificantNumber method

String getNationalSignificantNumber(
  1. PhoneNumber number
)

Gets the national significant number of a phone number. Note a national significant number doesn't contain a national prefix or any formatting.

number the phone number for which the national significant number is needed.

Implementation

String getNationalSignificantNumber(PhoneNumber number) {
  if (!number.hasNationalNumber()) return '';
  String nationalNumber = '${number.nationalNumber}';
  // If leading zero(s) have been set, we prefix this now. Note that a single
  // leading zero is not the same as a national prefix; leading zeros should be
  // dialled no matter whether you are dialling from within or outside the
  // country, national prefixes are added when formatting nationally if
  // applicable.
  if (number.italianLeadingZero && number.numberOfLeadingZeros > 0) {
    final leadingZeros =
        List.filled((number.numberOfLeadingZeros), '0').join();
    return '$leadingZeros$nationalNumber';
  }
  return nationalNumber;
}