syncSession property

Session syncSession

The Session for this Realm. The sync session is responsible for two-way synchronization with MongoDB Atlas. If the Realm is not synchronized, accessing this property will throw.

Implementation

Session get syncSession {
  if (config is! FlexibleSyncConfiguration) {
    throw RealmError('session is only valid on synchronized Realms (i.e. opened with FlexibleSyncConfiguration)');
  }

  var result = _syncSession?.target;

  if (result == null || result.handle.released) {
    result = SessionInternal.create(realmCore.realmGetSession(this));
    _syncSession = WeakReference(result);
  }

  return result;
}