• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
No results for ""


Flutter SDK reference

Read time: 1 minute
Last edited: Dec 04, 2021


This reference guide documents the methods available in the Flutter SDK, and explains in detail how these methods work. LaunchDarkly's SDKs are open source. The source is available in GitHub or the generated API documentation. You can also try this SDK out by cloning and running a sample application that uses this SDK.

Supported platforms

The Flutter SDK supports Android API 21+ and iOS 10.0+. Other Flutter platforms are not supported by this SDK.

Getting started

After you complete the Getting Started process, follow these instructions to start using the LaunchDarkly SDK in your Flutter mobile application.

To get started, declare a dependency on the LaunchDarkly Flutter SDK:

1launchdarkly_flutter_client_sdk: ^1.0.0

Then, import the package in your application code:

1import 'package:launchdarkly_flutter_client_sdk/launchdarkly_flutter_client_sdk.dart';

After you install the SDK, initialize the single shared instance of LDClient. This authorizes your application to connect to LaunchDarkly and retrieve flag values for your application and environment. To create a client instance, you need your environment's mobile key, available in the Projects tab of your account settings page. Be sure to use a mobile key. Never embed a server-side SDK key into a mobile application.

The following example shows how to create the client:

1LDConfig config = LDConfigBuilder('YOUR_MOBILE_KEY').build();
2LDUser user = LDUserBuilder('user key')
3 .email('fake@example.com')
4 .build();
6await LDClient.start(config, user);
Making feature flags available to this SDK

You must make feature flags available to mobile SDKs before the flags can be evaluated. If an SDK tries to evaluate a feature flag that is not available, the user will receive the default value for that flag.

To make a flag available to this SDK, check the SDKs using Mobile key checkbox during flag creation, or on the flag's Settings tab. To make all of a project's flags available to this SDK by default, check the SDKs using Mobile key checkbox in your project Settings.

Using LDClient, you can check which variation a particular user should receive for a given feature flag:

1bool showFeature = await LDClient.boolVariation(flagKey, false);
2if (showFeature) {
3 // application code to show the feature
5else {
6 // the code to run if the feature is off

Lastly, shut down the client when your application terminates. To learn more, read Shutting down.

Data collection

To learn more about data collection within this SDK and implications on submissions to the Apple App Store, read Apple App Store data collection policy.

Supported features

This SDK supports the following features: