https://github.com/genkey6/ld-relay-client-dart
A client implementation for Relay Proxy of LaunchDarkly in Dart
https://github.com/genkey6/ld-relay-client-dart
feature-flags feature-toggles launchdarkly
Last synced: 4 months ago
JSON representation
A client implementation for Relay Proxy of LaunchDarkly in Dart
- Host: GitHub
- URL: https://github.com/genkey6/ld-relay-client-dart
- Owner: genkey6
- License: other
- Created: 2023-12-09T09:14:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-30T21:55:28.000Z (5 months ago)
- Last Synced: 2026-01-31T13:32:23.583Z (5 months ago)
- Topics: feature-flags, feature-toggles, launchdarkly
- Language: Dart
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ld-relay-client-dart
[](https://github.com/genkey6/ld-relay-client-dart/actions/workflows/ci.yaml)
[](https://pub.dev/packages/ld_relay_client)
A client implementation for [Relay Proxy](https://docs.launchdarkly.com/home/relay-proxy) of [LaunchDarkly](https://launchdarkly.com/) in Dart.
## How to use
### Step 1: Installation
```
dart pub add ld_relay_client
```
### Step 2: Initialize the client
```dart
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 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(),
);
```
### Step 3: Evaluate the flag value and switch the logic
```dart
// 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
}
```