asyncUpdateToFromData method

void asyncUpdateToFromData(
  1. void onComplete(
    1. GemError err
    )
)

Asynchronously fetch and update full fromLandmark and toLandmark details from the server.

When a landmark returned by fromLandmark/toLandmark does not contain detailed address or description information, call this method to fetch the missing data.

The provided onComplete callback receives a GemError indicating success or the failure reason.

Parameters

  • onComplete: callback invoked with a GemError when the operation finishes. Typical values:

Example

routeEvent.asyncUpdateToFromData((GemError err) {
  if (err == GemError.success) {
    final (Landmark updatedStart, bool cacheStart) =
        routeEvent.fromLandmark;
    final (Landmark updatedEnd, bool cacheEnd) = routeEvent.toLandmark;
    print('Updated start landmark: $updatedStart');
  } else {
    print('Failed to update landmarks: $err');
  }
});

See also:

  • fromLandmark — Start landmark of the traffic event on the route.
  • toLandmark — End landmark of the traffic event on the route.
  • cancelUpdate — Cancel a pending update request.

Implementation

void asyncUpdateToFromData(final void Function(GemError err) onComplete) {
  final EventDrivenProgressListener listener = EventDrivenProgressListener();
  GemKitPlatform.instance.registerEventHandler(listener.id, listener);

  listener.registerOnCompleteWithData((final int err, final _, final _) {
    onComplete(GemErrorExtension.fromCode(err));
  });

  final OperationResult resultString = objectMethod(
    pointerId,
    'RouteTrafficEvent',
    'asyncUpdateToFromData',
    args: listener.id,
  );

  final int error = resultString['gemApiError'];
  if (error != 0) {
    onComplete(GemErrorExtension.fromCode(error));
  }
}