For the complete documentation index, see llms.txt. This page is also available as Markdown.

Dart SDK

Add feature flags and experimentation to your Dart and Flutter applications with the Harness FME Dart Client SDK, running on the Dart VM and Flutter across Android, iOS, Web, and Desktop.

Add feature flags and experimentation to your Dart and Flutter applications with the Harness FME Dart Client SDK.

This guide provides detailed information about our Dart Client SDK, splitio_client_side. The SDK runs on the Dart VM and Flutter across every target platform (Android, iOS, Web, and Desktop), and is pure Dart with no dart:html, dart:io, or dart:ffi dependencies, so it works anywhere Dart or Flutter runs.

All of our SDKs are open source. Go to our Dart Client SDK GitHub repository to see the source code, or view the package on pub.dev.

Before you begin

This SDK requires Dart SDK v3.0.0 or later.

Initialization

Set up Harness FME in your code base with the following steps:

1. Add the package to your pubspec.yaml file

dependencies:
  splitio_client_side: ^1.1.0

2. Instantiate the SDK factory

import 'package:splitio_client_side/splitio_client_side.dart';

final factory = SplitFactory.create(
  'YOUR_SDK_KEY',
  const SplitClientConfig(),
  'CUSTOMER_ID',
);
final client = factory.client('CUSTOMER_ID');

Configure the SDK with the SDK key for the FME environment that you would like to access. Select a client-side SDK API key. This is a special type of API token with limited privileges for use in browsers or mobile clients. Go to API keys to learn more.

Using the SDK

Basic use

When the SDK is instantiated, it starts background tasks to update an in-memory cache with small amounts of data fetched from Harness servers. Because this SDK is meant to be used client-side, do not block your app on SDK readiness. Instead, subscribe to the whenReady() future, as shown below.

After the SDK is ready, use the getTreatment method to return the proper treatment based on the FEATURE_FLAG_NAME and the key you passed when instantiating the client. Then use an if-else-if block as shown below and insert the code for the different treatments that you defined in Harness FME. Remember the final else branch in your code to handle the client returning the control treatment.

Subscribe to updates

Because feature flag definitions can change at any time, listen to the client's whenUpdated() stream to know when to re-evaluate flags, rather than relying on a value you evaluated earlier in the session.

Questions or feedback? Reach out to your Harness account team, or open an issue in the GitHub repository above.

Last updated

Was this helpful?