Flutter SDK
Evaluate feature flags in Flutter
Read customer-targeted flags synchronously, await fresh evaluations, and rebuild Flutter UI when values change.
Read a feature flag
Feature flags load automatically after BTX has an identified customer. Reads are synchronous and return the supplied fallback while state is unloaded or a key is unknown.
final isEnabled = Btx.isFeatureEnabled(
'settings.messenger-entry.enabled',
fallback: false,
);Choose a fallback that keeps the host app safe when an evaluation is not yet available.
Wait for pending SDK work
Use featureFlagEnabled(...) when a flow must wait for configure and identity
work. Set refresh: true only when the decision needs a new server evaluation.
final isEnabled = await Btx.featureFlagEnabled(
'settings.messenger-entry.enabled',
fallback: false,
refresh: true,
);For an explicit state refresh, call await Btx.refreshFeatureFlags() and read
the returned BtxFeatureFlagsState or the current Btx.featureFlags snapshot.
Rebuild UI when flags change
Listen to Btx.featureFlagsListenable when host UI should react to initial
evaluation, foreground refresh, identity replacement, or an explicit refresh.
ValueListenableBuilder<BtxFeatureFlagsState>(
valueListenable: Btx.featureFlagsListenable,
builder: (context, flags, child) {
final enabled = flags.isEnabled(
'settings.messenger-entry.enabled',
fallback: false,
);
return enabled ? const MessengerEntry() : const SizedBox.shrink();
},
)The state contains values, loaded, revision, and evaluatedAt. Loaded
flags stay stable through routine session refresh and flush work for the same
customer.
Keep flags customer-scoped
Flags clear to the unloaded state on sign-out, customer replacement, or SDK disposal. Identify the same stable customer described in the identity guide before making customer-targeted decisions.