getNamedNumberOrDefault method

double getNamedNumberOrDefault(
  1. String name,
  2. double defaultValue
)

Implementation

double getNamedNumberOrDefault(String name, double defaultValue) {
  final retValuePtr = calloc<Double>();
  final nameHstring = convertToHString(name);

  try {
    final hr = ptr.ref.vtable
            .elementAt(10)
            .cast<
                Pointer<
                    NativeFunction<
                        HRESULT Function(Pointer, IntPtr name,
                            Double defaultValue, Pointer<Double>)>>>()
            .value
            .asFunction<
                int Function(Pointer, int name, double defaultValue,
                    Pointer<Double>)>()(
        ptr.ref.lpVtbl, nameHstring, defaultValue, retValuePtr);

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

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

    free(retValuePtr);
  }
}