requestAccessAsync method

Future<GeolocationAccessStatus> requestAccessAsync()

Implementation

Future<GeolocationAccessStatus> requestAccessAsync() {
  final retValuePtr = calloc<COMObject>();
  final completer = Completer<GeolocationAccessStatus>();

  final hr = ptr.ref.vtable
          .elementAt(6)
          .cast<
              Pointer<
                  NativeFunction<
                      HRESULT Function(Pointer, Pointer<COMObject>)>>>()
          .value
          .asFunction<int Function(Pointer, Pointer<COMObject>)>()(
      ptr.ref.lpVtbl, retValuePtr);

  if (FAILED(hr)) {
    free(retValuePtr);
    throw WindowsException(hr);
  }

  final asyncOperation =
      IAsyncOperation<GeolocationAccessStatus>.fromRawPointer(retValuePtr,
          enumCreator: GeolocationAccessStatus.from, intType: Int32);
  completeAsyncOperation(
      asyncOperation, completer, asyncOperation.getResults);

  return completer.future;
}