LDClient class Null safety

The main interface for the LaunchDarkly Flutter SDK.

To setup the SDK before use, build an LDConfig with LDConfigBuilder and an initial LDUser with LDUserBuilder. These should be passed to LDClient.start to initialize the SDK instance. A basic example:

LDConfig config = LDConfigBuilder('<YOUR_MOBILE_KEY>').build();
LDUser user = LDUserBuilder('<USER_KEY>').build();
await LDClient.start(config, user);

After initialization, the SDK can evaluate feature flags from the LaunchDarkly dashboard against the current user, record custom events, and provides various status configuration and monitoring utilities. See the individual class and method documentation for more details.

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Methods

alias(LDUser user, LDUser previousUser) Future<void>
Alias associates two users for analytics purposes. [...]
allFlags() Future<Map<String, LDValue>>
Returns a map of all feature flags for the current user, without sending evaluation events to LaunchDarkly. [...]
boolVariation(String flagKey, bool defaultValue) Future<bool>
Returns the value of flag flagKey for the current user as a bool. [...]
boolVariationDetail(String flagKey, bool defaultValue) Future<LDEvaluationDetail<bool>>
Returns the value of flag flagKey for the current user as a bool, along with information about the resultant value. [...]
close() Future<void>
Permanently shuts down the client. [...]
doubleVariation(String flagKey, double defaultValue) Future<double>
Returns the value of flag flagKey for the current user as a double. [...]
doubleVariationDetail(String flagKey, double defaultValue) Future<LDEvaluationDetail<double>>
Returns the value of flag flagKey for the current user as a double, along with information about the resultant value. [...]
flush() Future<void>
Triggers immediate sending of pending events to LaunchDarkly. [...]
getConnectionInformation() Future<LDConnectionInformation?>
Returns information about the current state of the SDK's connection to the LaunchDarkly. [...]
identify(LDUser user) Future<void>
Changes the active user context. [...]
intVariation(String flagKey, int defaultValue) Future<int>
Returns the value of flag flagKey for the current user as an int. [...]
intVariationDetail(String flagKey, int defaultValue) Future<LDEvaluationDetail<int>>
Returns the value of flag flagKey for the current user as an int, along with information about the resultant value. [...]
isInitialized() bool
Checks whether the SDK has completed starting. [...]
isOffline() Future<bool>
Returns whether the SDK is currently configured not to make network connections.
jsonVariation(String flagKey, LDValue defaultValue) Future<LDValue>
Returns the value of flag flagKey for the current user as an LDValue. [...]
jsonVariationDetail(String flagKey, LDValue defaultValue) Future<LDEvaluationDetail<LDValue>>
Returns the value of flag flagKey for the current user as an LDValue, along with information about the resultant value. [...]
registerFeatureFlagListener(String flagKey, LDFlagUpdatedCallback flagUpdateCallback) Future<void>
Registers a callback to be notified when the value of the flag flagKey is updated.
registerFlagsReceivedListener(LDFlagsReceivedCallback flagsReceivedCallback) Future<void>
Registers a callback to be notified when flag data is received by the SDK.
setOnline(bool online) Future<void>
Shuts down or restores network activity made by the SDK. [...]
start(LDConfig config, LDUser user) Future<void>
Initialize the SDK with the given LDConfig and LDUser. [...]
startFuture({Duration? timeLimit}) Future<void>
Returns a future that completes when the SDK has completed starting. [...]
stringVariation(String flagKey, String? defaultValue) Future<String?>
Returns the value of flag flagKey for the current user as a string. [...]
stringVariationDetail(String flagKey, String? defaultValue) Future<LDEvaluationDetail<String?>>
Returns the value of flag flagKey for the current user as a string, along with information about the resultant value. [...]
track(String eventName, {LDValue? data, num? metricValue}) Future<void>
Track custom events associated with the current user for data export or experimentation. [...]
unregisterFeatureFlagListener(String flagKey, LDFlagUpdatedCallback flagUpdateCallback) Future<void>
Unregisters an LDFlagUpdatedCallback from the flagKey flag.
unregisterFlagsReceivedListener(LDFlagsReceivedCallback flagsReceivedCallback) Future<void>
Unregisters an LDFlagsReceivedCallback.