getGeopositionHistoryAsync method

Future<List<Geoposition>> getGeopositionHistoryAsync(
  1. DateTime startTime
)

Implementation

Future<List<Geoposition>> getGeopositionHistoryAsync(DateTime startTime) {
  final retValuePtr = calloc<COMObject>();
  final completer = Completer<List<Geoposition>>();
  final startTimeDateTime =
      startTime.difference(DateTime.utc(1601, 01, 01)).inMicroseconds * 10;

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

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

  final asyncOperation =
      IAsyncOperation<IVectorView<Geoposition>>.fromRawPointer(
          retValuePtr,
          creator: (Pointer<COMObject> ptr) => IVectorView.fromRawPointer(ptr,
              creator: Geoposition.fromRawPointer,
              iterableIid: '{135ed72d-75b1-5881-be41-6ffeaa202044}'));
  completeAsyncOperation(
      asyncOperation, completer, () => asyncOperation.getResults().toList());

  return completer.future;
}