Skip to content

Flutter Feature Flags Quickstart

This guide gets you from zero to evaluating a feature flag in a Flutter application. The SDK is a client-side SDK — flags are evaluated server-side and only values are returned.

  • A Featureflip account with at least one feature flag created
  • A client SDK key from your environment settings
  • Flags you want to use must have Client-side visible enabled
  • Flutter 3.24+ / Dart 3.5+

Add the package to your pubspec.yaml:

dependencies:
featureflip: ^2.0.0

Then run:

Terminal window
flutter pub get
import 'package:featureflip/featureflip.dart';
final config = FeatureflipConfig(
clientKey: 'your-client-sdk-key',
context: {'user_id': 'user-123'},
);
final client = FeatureflipClient.get('your-client-sdk-key', config: config);
await client.initialize();

initialize() fetches flag values from the evaluation API and starts SSE streaming for real-time updates.

final showBanner = client.boolVariation('new-banner', defaultValue: false);
if (showBanner) {
print('Showing the new banner');
} else {
print('Using the default experience');
}

The defaultValue parameter is returned when the flag is missing or has an unexpected type.

Other variation methods are available for different value types:

final color = client.stringVariation('banner-color', defaultValue: 'blue');
final limit = client.numberVariation('rate-limit', defaultValue: 100.0);

Close the client when your app is shutting down:

await client.close();

The SDK automatically pauses streaming when the app enters the background and resumes on foreground.

The Flutter SDK is a client-side SDK — flags are evaluated on the Featureflip server, not locally in your app. On initialization, the SDK sends the user context to the evaluation API and receives pre-evaluated flag values. It then opens an SSE (Server-Sent Events) connection that pushes updates in real-time whenever flags change in the dashboard.

When the app moves to the background, the SDK pauses the SSE connection to conserve battery and data. It resumes streaming when the app returns to the foreground, fetching any updates that occurred while paused.

initialize() hangs or returns unexpected values

Verify you are using a client SDK key (not a server SDK key). Client and server keys are different — using the wrong type results in authentication errors or empty responses. Also confirm that the flags you want to access have Client-side visible enabled in the dashboard.

Flag values do not update after changes in the dashboard

The SDK uses SSE streaming for real-time updates. On emulators, SSE connections can be less reliable than on physical devices. If updates seem stuck, try restarting the app or testing on a real device. Also check that your network environment does not block long-lived HTTP connections.

MissingPluginException or build failures

The SDK requires Flutter 3.24+ and Dart 3.5+. Run flutter --version to check your version and upgrade if needed. If you see build errors after adding the dependency, run flutter clean followed by flutter pub get to clear the build cache.