Kubesense Flags Flutter
kubesense_flags_flutter integrates the standalone
kubesense_flags Dart package with
kubesense_flutter_plugin.
Use this package when your Flutter app already initializes the Kubesense Flutter SDK and you want feature flags to reuse that configuration.
Getting Started
Add the package:
flutter pub add kubesense_flags_flutter
This package requires Dart 3.6 or later and Flutter 3.27 or later. It depends
on kubesense_flutter_plugin 3.4.0 or later.
Register the plugin before initializing the Kubesense Flutter SDK:
import 'package:kubesense_flags_flutter/kubesense_flags_flutter.dart';
import 'package:kubesense_flutter_plugin/kubesense_flutter_plugin.dart';
final configuration = KubesenseConfiguration(
clientToken: '<CLIENT_TOKEN>',
env: '<ENV_NAME>',
kubesenseRumEndpoint: 'us2.kubesense.ai',
rumConfiguration: KubesenseRumConfiguration(
applicationId: '<RUM_APPLICATION_ID>',
),
)..addPlugin(const KubesenseFlagsPluginConfiguration());
await KubesenseSdk.instance.initialize(configuration, TrackingConsent.granted);
Evaluate flags with the same typed API as kubesense_flags:
final flags = KubesenseSdk.instance.flags;
final client = flags?.sharedClient();
await client?.initialize(
const FlagsEvaluationContext(targetingKey: 'user-123'),
);
final details = client?.getBooleanDetails(
key: 'checkout.enabled',
defaultValue: false,
);
Successful evaluations emit feature flag telemetry through kubesense_flags.
When RUM is enabled, successful evaluations are also added to the active RUM
view with KubesenseRum.addFeatureFlagEvaluation.
To evaluate flags without adding successful evaluations to the active RUM view, disable RUM integration when registering the plugin:
final configuration = KubesenseConfiguration(
clientToken: '<CLIENT_TOKEN>',
env: '<ENV_NAME>',
kubesenseRumEndpoint: 'us2.kubesense.ai',
)..addPlugin(
const KubesenseFlagsPluginConfiguration(
rumIntegrationEnabled: false,
),
);
Custom Flags Configuration
By default, kubesense_flags_flutter derives the client token, environment,
collector endpoint, application ID, service, and version from KubesenseConfiguration. Pass a
KubesenseFlagsConfiguration to override the standalone Flags SDK configuration:
KubesenseFlagsPluginConfiguration(
flagsConfiguration: KubesenseFlagsConfiguration(
kubesenseConfig: KubesenseFlagsConfig(
clientToken: '<CLIENT_TOKEN>',
env: '<ENV_NAME>',
kubesenseRumEndpoint: 'us2.kubesense.ai',
),
),
);
Use package:kubesense_flags/kubesense_flags.dart directly for pure Dart apps or
Flutter apps that need full lifecycle control without Kubesense Flutter SDK
integration.
Background Isolates
kubesense_flags_flutter does not support evaluation from background
isolates. If your app needs to evaluate flags from a background isolate, create
and initialize a standalone kubesense_flags client in that isolate.