getParsableNumber method Null safety

Future<String> getParsableNumber(
  1. PhoneNumber phoneNumber
)

Accepts a PhoneNumber object and returns a formatted phone number String

Implementation

static Future<String> getParsableNumber(PhoneNumber phoneNumber) async {
  if (phoneNumber.isoCode != null) {
    PhoneNumber 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 {
    print('ISO Code is "${phoneNumber.isoCode}"');
    return '';
  }
}