formatWithOutputFormat method

String formatWithOutputFormat(
  1. PhoneNumberInfo number,
  2. PhoneNumberFormat numberFormat
)

Implementation

String formatWithOutputFormat(
    PhoneNumberInfo number, PhoneNumberFormat numberFormat) {
  final retValuePtr = calloc<HSTRING>();

  try {
    final hr = ptr.ref.vtable
            .elementAt(7)
            .cast<
                Pointer<
                    NativeFunction<
                        HRESULT Function(Pointer, Pointer<COMObject> number,
                            Int32 numberFormat, Pointer<IntPtr>)>>>()
            .value
            .asFunction<
                int Function(Pointer, Pointer<COMObject> number,
                    int numberFormat, Pointer<IntPtr>)>()(
        ptr.ref.lpVtbl,
        number.ptr.cast<Pointer<COMObject>>().value,
        numberFormat.value,
        retValuePtr);

    if (FAILED(hr)) throw WindowsException(hr);

    final retValue = retValuePtr.toDartString();
    return retValue;
  } finally {
    WindowsDeleteString(retValuePtr.value);
    free(retValuePtr);
  }
}