ConfigCatClient.get constructor

ConfigCatClient.get({
  1. required String sdkKey,
  2. ConfigCatOptions options = ConfigCatOptions.defaultOptions,
})

Creates a new or gets an already existing ConfigCatClient for the given sdkKey.

Implementation

factory ConfigCatClient.get(
    {required String sdkKey,
    ConfigCatOptions options = ConfigCatOptions.defaultOptions}) {
  if (sdkKey.isEmpty) {
    throw ArgumentError('The SDK key cannot be empty.');
  }

  var client = _instanceRepository[sdkKey];
  if (client != null && options != ConfigCatOptions.defaultOptions) {
    client._logger.warning(3000,
        "There is an existing client instance for the specified SDK Key. No new client instance will be created and the specified options are ignored. Returning the existing client instance. SDK Key: '$sdkKey'.");
  }
  client ??= _instanceRepository[sdkKey] = ConfigCatClient._(sdkKey, options);
  return client;
}