chameleon_pilot_sdk 0.1.6 copy "chameleon_pilot_sdk: ^0.1.6" to clipboard
chameleon_pilot_sdk: ^0.1.6 copied to clipboard

Flutter SDK for ChameleonPilot runtime config, updates, maintenance, and feature flags.

ChameleonPilot SDK #

Flutter SDK for reading ChameleonPilot runtime configuration with one init call.

Install #

dependencies:
  chameleon_pilot_sdk: ^0.1.0

Initialize once #

Call initialize when your app starts. The SDK clears any old cached response, calls /chameleonpilot/sdk/init, then stores the fresh response in SharedPreferences for later reads. If appVersion is omitted, the SDK reads it from the installed app with package_info_plus.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await ChameleonPilot.initialize(
    baseUrl: 'https://your-pocketbase-domain.com',
    apiKey: 'cpk...',
    navigatorKey: yourNavigatorKey,
  );

  runApp(const MyApp());
}

Optional backend config versions can be pinned when needed:

await ChameleonPilot.initialize(
  baseUrl: 'https://your-pocketbase-domain.com',
  apiKey: 'cpk...',
  appVersion: '1.0.0',
  updateVersion: 2,
  maintenanceVersion: 1,
  featureFlagsVersion: 4,
);

Read config #

final update = ChameleonPilot.update;
final maintenance = ChameleonPilot.maintenance;

await ChameleonPilot.showUpdate();
await ChameleonPilot.showMaintenance();

final color = ChameleonPilot.getFlag<String>(
  'theme_color',
  fallback: '#2D6A4F',
);

final homeLayout = ChameleonPilot.layout('home');
for (final item in homeLayout?.items ?? const []) {
  // Resolve item.id through your app's widget registry.
  final widgetBuilder = widgetRegistry[item.id];
  if (item.enabled && widgetBuilder != null) {
    // Render widgetBuilder(context, item) in this server-defined order.
  }
}

// The example app includes two optional screens and three registry IDs:
// home/menu and widget_1/widget_2/widget_3. Create and publish those layouts
// in the dashboard to see the configured order in the example.
final menuLayout = ChameleonPilot.layout('menu');

// For a reusable renderer, the SDK can apply the published order and layout
// type for you. The app only maps IDs to its own widgets:
ChameleonPilotLayoutView(
  screen: 'home',
  registry: {
    'widget_1': (_, item) => const WidgetOne(),
    'widget_2': (_, item) => const WidgetTwo(),
    'widget_3': (_, item) => const WidgetThree(),
  },
  empty: const SizedBox.shrink(),
);

ChameleonPilotLayoutView is optional; apps that need custom composition can use ChameleonPilot.layoutItems(...) instead.

update and maintenance are null when there is no issue for the current app version. Feature flags are returned as a list and can also be read by key.

Example #

Run the sample app from example/:

cd example
flutter run --dart-define=CHAMELEON_BASE_URL=http://127.0.0.1:8090

Paste your cpk... API key in the first screen after the example app opens.

0
likes
110
points
174
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter SDK for ChameleonPilot runtime config, updates, maintenance, and feature flags.

Repository (GitHub)

Topics

#remote-config #feature-flags #maintenance #updates

License

MIT (license)

Dependencies

flutter, http, package_info_plus, shared_preferences, url_launcher

More

Packages that depend on chameleon_pilot_sdk