OpenFeature Dart Client SDK

This package is the vendor-neutral OpenFeature SDK for Dart client applications. It uses the static-context paradigm. It has no Flutter or dart:io dependency.

This package supports Dart 3.10 or later within Dart 3.x. Provider packages can require a higher Dart version; check the chosen provider separately.

Current package version: 0.0.1.

Release status: 0.0.1 is the first non-beta client release. The SDK remains pre-1.0.

This package provides synchronous typed evaluation, event handlers, hooks, ordered context changes and an in-memory provider. Pre-1.0 versions do not establish a 1.0 API compatibility commitment. Consult the conformance matrix and release notes for accepted support scope.

Install

The client SDK requires Dart 3.10 or later within Dart 3.x. Flutter applications need a Flutter release that includes a compatible Dart SDK.

dependencies:
  openfeature_dart_client_sdk: ^0.0.1 # x-release-please-version

Run dart pub get, or flutter pub get in a Flutter application.

Use the client

import 'package:openfeature_dart_client_sdk/openfeature_dart_client_sdk.dart';

Future<void> main() async {
  final provider = InMemoryProvider({
    'new-checkout': true,
    'welcome-message': 'Hello',
  });

  await OpenFeatureAPI.instance.setProviderAndWait(provider);
  await OpenFeatureAPI.instance.setEvaluationContextAndWait(
    EvaluationContext(targetingKey: 'user-123'),
  );

  final client = OpenFeatureAPI.instance.getClient('checkout');
  final enabled = client.getBooleanValue('new-checkout', false);
  final message = client.getStringValue('welcome-message', 'Welcome');

  print('$enabled: $message');
  await OpenFeatureAPI.instance.shutdown();
}

Implement a provider

Implement FeatureProvider with synchronous resolvers. A resolver must use local state. It must not perform network, file, or platform-channel I/O.

Implement only the optional capabilities that the provider needs:

  • InitializableProvider for asynchronous initialization.
  • ContextReconciliationProvider for static-context changes.
  • ShutdownProvider for resource cleanup.
  • ProviderEventSource for provider lifecycle events.
  • DomainScopedProvider when one provider instance supports one domain.
  • TrackingProvider for non-blocking tracking.

An initializable or reconciling provider must also implement ProviderEventSource. It must emit the terminal lifecycle event before its method terminates. The SDK bounds lifecycle waits to 30 seconds by default so a provider contract violation cannot indefinitely block context changes or shutdown. Tests and isolated integrations may select a shorter timeout through createIsolatedOpenFeatureAPI(lifecycleTimeout: ...).

When initialization or context reconciliation times out, the SDK quarantines and detaches that provider instance. Its underlying asynchronous work cannot be cancelled safely, so applications must register a new provider instance rather than retrying the timed-out one. Subscription cancellation and shutdown cleanup are bounded by the same timeout.

A provider that implements ContextReconciliationProvider can have only one active API/domain binding. Use a separate provider instance for each static context. Providers that resolve entirely from the context passed to each resolver and do not reconcile cached state may be shared across domains.

The server and client packages share the open-feature/dart-sdk repository. The repository rename preserves this package name, Dart imports, and independent client releases.

Scope

This package does not include an HTTP transport, an OFREP provider, a vendor provider, persistent storage, or Flutter APIs.

Validate the package archive

Run the repository staging command to create and validate the same isolated client archive used by the publication workflow:

dart tool/stage_client_package.dart --dry-run

See the client release procedure for non-beta release review and historical first-publication instructions.

Libraries

openfeature_dart_client_sdk
Pure Dart OpenFeature client SDK for the static-context paradigm.
openfeature_dart_client_sdk_experimental
Experimental OpenFeature Dart client APIs.