Skip to content

Commit a68deb2

Browse files
committed
feat: expose the FDv2 data system through the Flutter SDK
Surface the FDv2 data acquisition protocol on the public Flutter API: - LDConfig gains a dataSystem option (opts into FDv2; early access). - LDClient.setConnectionMode([ConnectionMode?]) applies a manual connection-mode override (sticks and suppresses automatic transitions; null clears it). - Export the data-system configuration types (DataSystemConfig, ConnectionModeId, ModeDefinition, EndpointConfig, the initializer / synchronizer entries, and Fdv1FallbackConfig) and drop the internal FDv2* connection-mode types from the public surface. The data system itself is built in common_client; this is the Flutter wiring that lets applications configure and use it.
1 parent b0b16cd commit a68deb2

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

packages/flutter_client_sdk/lib/launchdarkly_flutter_client_sdk.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ export 'package:launchdarkly_common_client/launchdarkly_common_client.dart'
4545
PersistenceConfig,
4646
ApplicationInfo,
4747
ConnectionMode,
48-
FDv2ConnectionMode,
49-
FDv2Streaming,
50-
FDv2Polling,
51-
FDv2Offline,
52-
FDv2Background,
5348
ResolvedConnectionMode,
5449
ResolvedStreaming,
5550
ResolvedPolling,
@@ -73,7 +68,19 @@ export 'package:launchdarkly_common_client/launchdarkly_common_client.dart'
7368
PluginCredentialInfo,
7469
PluginEnvironmentMetadata,
7570
PluginMetadata,
76-
PollingConfig;
71+
PollingConfig,
72+
DataSystemConfig,
73+
ConnectionModeId,
74+
ModeDefinition,
75+
EndpointConfig,
76+
InitializerEntry,
77+
SynchronizerEntry,
78+
CacheInitializer,
79+
PollingInitializer,
80+
StreamingInitializer,
81+
PollingSynchronizer,
82+
StreamingSynchronizer,
83+
Fdv1FallbackConfig;
7784

7885
export 'src/ld_client.dart' show LDClient;
7986
export 'src/config/ld_config.dart' show LDConfig, ApplicationEvents;

packages/flutter_client_sdk/lib/src/config/ld_config.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ final class LDConfig extends LDCommonConfig {
9090
/// [plugins] can be used to add plugins to the SDK.
9191
///
9292
/// Plugin support is currently experimental and subject to change.
93+
///
94+
/// [dataSystem] opts the SDK into the FDv2 data acquisition protocol.
95+
/// This feature is not stable, and not subject to any backwards
96+
/// compatibility guarantees or semantic versioning. It is in early access.
9397
LDConfig(super.sdkCredential, super.autoEnvAttributes,
9498
{super.applicationInfo,
9599
super.httpProperties,
@@ -103,7 +107,8 @@ final class LDConfig extends LDCommonConfig {
103107
super.globalPrivateAttributes,
104108
ApplicationEvents? applicationEvents,
105109
super.hooks,
106-
List<Plugin>? plugins})
110+
List<Plugin>? plugins,
111+
super.dataSystem})
107112
: applicationEvents = applicationEvents ?? ApplicationEvents(),
108113
plugins =
109114
plugins != null ? UnmodifiableListView(List.from(plugins)) : null;

packages/flutter_client_sdk/lib/src/ld_client.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,27 @@ interface class LDClient {
343343
_connectionManager.offline = offline;
344344
}
345345

346+
/// Set the connection mode the SDK uses for data acquisition.
347+
///
348+
/// The mode is applied as a manual override: it sticks and suppresses
349+
/// automatic state-detection transitions (backgrounding, network
350+
/// availability) until cleared. Call with no argument (or null) to clear
351+
/// the override and resume automatic mode resolution.
352+
///
353+
/// This method is not stable, and not subject to any backwards
354+
/// compatibility guarantees or semantic versioning. It is in early
355+
/// access. If you want access to this feature please join the EAP.
356+
/// https://launchdarkly.com/docs/sdk/features/data-saving-mode
357+
void setConnectionMode([ConnectionMode? mode]) {
358+
_connectionManager.setMode(mode == null
359+
? null
360+
: switch (mode) {
361+
ConnectionMode.streaming => const FDv2Streaming(),
362+
ConnectionMode.polling => const FDv2Polling(),
363+
ConnectionMode.offline => const FDv2Offline(),
364+
});
365+
}
366+
346367
/// Check if the SDK has finished initialization.
347368
///
348369
/// This does not indicate that initialization was successful, but that it is

0 commit comments

Comments
 (0)