Last updated:
0 purchases
ld relay client
ld-relay-client-dart #
A client implementation for Relay Proxy of LaunchDarkly in Dart.
How to use #
Step 1: Installation #
dart pub add ld_relay_client
copied to clipboard
Step 2: Initialize the client #
import 'package:ld_relay_client/ld_relay_client.dart';
import 'package:http/http.dart' as http;
import 'package:logger/logger.dart';
final client = LDRelayClient(
LDRelayConfig(
sdkKey: '<your-server-sdk-key>', // your LaunchDarkly server-side SDK key (caution: The SDK key should be kept a secret)
ldRelayBaseUrl: 'http://localhost:8030', // the base URL for Relay Proxy
),
http.Client(),
Logger(),
);
copied to clipboard
Step 3: Evaluate the flag value and switch the logic #
// with single context
final evalResultWithSingleContext =
await client.boolVariation('flag-key1', false, {
'user': LaunchDarklyContextAttribute(key: 'user1'),
});
if (evalResultWithSingleContext) {
// do something
} else {
// do something else
}
// with multi contexts
final evalResultWithMultiContext =
await client.boolVariation('flag-key2', false, {
'user': LaunchDarklyContextAttribute(key: 'user2'),
'tenant': LaunchDarklyContextAttribute(key: 'tenant2'),
});
if (evalResultWithMultiContext) {
// do something
} else {
// do something else
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.