SyncClient constructor

SyncClient(
  1. Store _store,
  2. String serverUri,
  3. SyncCredentials creds
)

Creates a sync client associated with the given store and options. This does not initiate any connection attempts yet: call start() to do so.

Implementation

SyncClient(this._store, String serverUri, SyncCredentials creds) {
  if (!Sync.isAvailable()) {
    throw UnsupportedError(
        'Sync is not available in the loaded ObjectBox runtime library. '
        'Please visit https://objectbox.io/sync/ for options.');
  }

  final cServerUri = serverUri.toNativeUtf8();
  try {
    _cSync = checkObxPtr(
        C.sync1(InternalStoreAccess.ptr(_store), cServerUri.cast()),
        'failed to create sync client');
  } finally {
    malloc.free(cServerUri);
  }

  setCredentials(creds);
}