create static method

Future<AtClient> create(
  1. String currentAtSign,
  2. String? namespace,
  3. AtClientPreference preferences, {
  4. AtClientManager? atClientManager,
  5. RemoteSecondary? remoteSecondary,
  6. EncryptionService? encryptionService,
  7. SecondaryKeyStore? localSecondaryKeyStore,
  8. AtChops? atChops,
  9. AtClientCommitLogCompaction? atClientCommitLogCompaction,
  10. AtClientConfig? atClientConfig,
})

Implementation

static Future<AtClient> create(
    String currentAtSign, String? namespace, AtClientPreference preferences,
    {AtClientManager? atClientManager,
    RemoteSecondary? remoteSecondary,
    EncryptionService? encryptionService,
    SecondaryKeyStore? localSecondaryKeyStore,
    AtChops? atChops,
    AtClientCommitLogCompaction? atClientCommitLogCompaction,
    AtClientConfig? atClientConfig}) async {
  atClientManager ??= AtClientManager.getInstance();
  currentAtSign = AtUtils.fixAtSign(currentAtSign);

  // Fetch cached AtClientImpl for re-use, or create a new one and init it
  AtClientImpl? atClientImpl;
  if (atClientInstanceMap.containsKey(currentAtSign)) {
    atClientImpl = atClientInstanceMap[currentAtSign];
  } else {
    atClientImpl = AtClientImpl._(
        currentAtSign, namespace, preferences, atClientManager,
        remoteSecondary: remoteSecondary,
        encryptionService: encryptionService,
        localSecondaryKeyStore: localSecondaryKeyStore,
        atChops: atChops,
        atClientCommitLogCompaction: atClientCommitLogCompaction,
        atClientConfig: atClientConfig);

    await atClientImpl._init();
  }

  await atClientImpl!._startCompactionJob();
  atClientManager.listenToAtSignChange(atClientImpl);

  atClientInstanceMap[currentAtSign] = atClientImpl;
  return atClientInstanceMap[currentAtSign];
}