Skip to content
Configuration

Flutter SDK

Configure BTX for Flutter

Configure the SDK once, select only the capabilities your app needs, and resolve platform-specific publishable keys.

Configure once

Call Btx.configure(...) during app startup before identifying a customer or using another BTX capability.

App startup
await Btx.configure(
  BtxConfiguration(
    publishableClientKey: 'cfk_...',
  ),
);
01

Choose enabled features

The default feature set is logs plus customer messages. Pass an explicit set for telemetry-only apps or to opt in to the knowledge base.

Logs, messages, and knowledge base
await Btx.configure(
  BtxConfiguration(
    publishableClientKey: 'cfk_...',
    features: const <BtxFeature>{
      BtxFeature.logs,
      BtxFeature.messenger,
      BtxFeature.knowledgeBase,
    },
  ),
);
  • BtxFeature.logs selects a telemetry-only integration; customer-targeted feature flags use the same telemetry session.
  • BtxFeature.messenger enables the packaged messenger, foreground updates, and push registration.
  • BtxFeature.knowledgeBase opts in to help content and also requires BtxFeature.messenger.
02

Resolve platform and variant keys

Apps with multiple mobile targets can provide one key set. BTX chooses the key that matches the current iOS bundle ID or Android package name and uses the default key when no explicit mapping matches.

Platform-aware key set
await Btx.configure(
  BtxConfiguration.withPublishableClientKeys(
    publishableClientKeys: const BtxPublishableClientKeys(
      defaultKey: 'cfk_ios_prod',
      iosBundleIds: <String, String>{
        'com.example.app.beta': 'cfk_ios_beta',
      },
      androidPackageNames: <String, String>{
        'com.example.app': 'cfk_android',
      },
    ),
    features: const <BtxFeature>{BtxFeature.logs},
  ),
);
03

Attach app context

BTX derives app version, build number, platform, bundle ID or package name, OS, device family or model, physical-device state, and SDK version automatically. Use BtxAppContext only for explicit version overrides or app-specific, low-cardinality attributes.

App context
await Btx.configure(
  BtxConfiguration(
    publishableClientKey: 'cfk_...',
    appContext: const BtxAppContext(
      attributes: <String, String>{
        'releaseRing': 'beta',
      },
    ),
  ),
);

The SDK ignores host attempts to replace its platform, OS, device, and SDK metadata keys. It does not collect advertising identifiers, persistent phone identifiers, serial numbers, user-assigned device names, storage readings, or memory readings.

04

Choose one presentation host

Use BtxHost for the normal widget-tree integration. If the app already owns a root navigator key, provide it to BtxConfiguration and BTX will attach its messenger and knowledge base overlays there.

Root navigator integration
final navigatorKey = GlobalKey<NavigatorState>();

await Btx.configure(
  BtxConfiguration(
    publishableClientKey: 'cfk_...',
    navigatorKey: navigatorKey,
  ),
);

MaterialApp(
  navigatorKey: navigatorKey,
  home: const MyAppHome(),
)