getParsableNumber static method

Future<String> getParsableNumber(
  1. PhoneNumberTest phoneNumber
)

Implementation

static Future<String> getParsableNumber(PhoneNumberTest phoneNumber) async {
  if (phoneNumber.isoCode != null) {
    PhoneNumberTest number = await getRegionInfoFromPhoneNumber(
      phoneNumber.phoneNumber!,
      phoneNumber.isoCode!,
    );
    String? formattedNumber = await PhoneNumberUtil.formatAsYouType(
      phoneNumber: number.phoneNumber!,
      isoCode: number.isoCode!,
    );
    return formattedNumber!.replaceAll(
      RegExp('^([\\+]?${number.dialCode}[\\s]?)'),
      '',
    );
  } else {
    throw new Exception('ISO Code is "${phoneNumber.isoCode}"');
  }
}