hostCloudAnchor method

Future<String> hostCloudAnchor(
  1. String anchorId, {
  2. int ttlDays = 1,
})

Uploads an anchor to Google Cloud Anchors and returns its cloud id.

Implementation

Future<String> hostCloudAnchor(String anchorId, {int ttlDays = 1}) async {
  final String? cloudId = await _invoke<String>("hostCloudAnchor", <String, Object?>{"id": anchorId, "ttlDays": ttlDays});
  if (cloudId == null) throw const UArException(code: UArErrorCode.unknown, message: "Hosting failed");
  final UArAnchor? anchor = value.anchors[anchorId];
  if (anchor != null) {
    value = value.copyWith(
      anchors: <String, UArAnchor>{
        ...value.anchors,
        anchorId: anchor.copyWith(cloudId: cloudId),
      },
    );
  }
  return cloudId;
}