initialize static method
Future<void>
initialize({
- String? apiKey,
- String? baseUrl,
- SDKEnvironment environment = SDKEnvironment.SDK_ENVIRONMENT_PRODUCTION,
Bring the SDK up: platform adapters, native load, auth, device registration, catalog, and telemetry.
A null apiKey runs keyless local mode; a null baseUrl uses the
default control plane for environment. Remote work continues in the
background after the call returns, so there is no second phase.
Throws SDKException when the native core cannot start or the configuration is rejected.
Implementation
static Future<void> initialize({
String? apiKey,
String? baseUrl,
SDKEnvironment environment = SDKEnvironment.SDK_ENVIRONMENT_PRODUCTION,
}) {
final existing = _initializationFuture;
if (existing != null) return existing;
final resetInProgress = _resetFuture;
final operation = () async {
if (resetInProgress != null) await resetInProgress;
await _initialize(_resolveParams(apiKey, baseUrl, environment));
}();
_initializationFuture = operation;
unawaited(_clearWhenSettled(operation, () => _initializationFuture, () {
_initializationFuture = null;
}));
return operation;
}