setNamedValue method

void setNamedValue(
  1. String name,
  2. IJsonValue? value
)

Implementation

void setNamedValue(String name, IJsonValue? value) {
  final nameHstring = convertToHString(name);

  final hr = ptr.ref.vtable
          .elementAt(7)
          .cast<
              Pointer<
                  NativeFunction<
                      HRESULT Function(
                          Pointer, IntPtr name, Pointer<COMObject> value)>>>()
          .value
          .asFunction<
              int Function(Pointer, int name, Pointer<COMObject> value)>()(
      ptr.ref.lpVtbl,
      nameHstring,
      value == null ? nullptr : value.ptr.cast<Pointer<COMObject>>().value);

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

  WindowsDeleteString(nameHstring);
}