Skip to main content
The feature flags module lets you enable or disable features remotely from the AppDNA Console. Flags are evaluated locally from cached config — no network call, no latency.

Check a Flag

if (AppDNA.features.isEnabled("dark_mode")) {
  enableDarkMode();
}
isEnabled() returns false by default if the flag does not exist or config has not loaded.

Module Access

final features = AppDNA.features;

Module Methods

MethodSignatureDescription
isEnabledbool isEnabled(String flag)Check if a feature flag is enabled
getAllFlagsMap<String, bool> getAllFlags()Get all flags and their states

Using Flags with Experiments

Gate a feature behind a flag, then run an experiment to test its impact:
if (AppDNA.features.isEnabled("new_workout_ui")) {
  final variant = AppDNA.experiments.getVariant("workout_ui_test");

  switch (variant) {
    case "compact":
      showCompactWorkoutUI();
      break;
    case "detailed":
      showDetailedWorkoutUI();
      break;
    default:
      showDefaultWorkoutUI();
  }
} else {
  showLegacyWorkoutUI();
}

FeatureFlagDelegate

class FlagHandler extends FeatureFlagDelegate {
  @override
  void onFlagChanged(String flag, bool enabled) {
    if (flag == "maintenance_mode" && enabled) {
      showMaintenanceScreen();
    }
  }
}

AppDNA.features.delegate = FlagHandler();

Full Example

import 'package:appdna_sdk/appdna_sdk.dart';

class FeatureGate {
  void checkAccess(String feature, {required VoidCallback onLocked, required VoidCallback onUnlocked}) {
    if (AppDNA.features.isEnabled(feature)) {
      onUnlocked();
    } else {
      onLocked();
    }
  }
}

// Usage
final gate = FeatureGate();

gate.checkAccess("ai_suggestions",
  onLocked: () {
    AppDNA.paywall.present("premium_paywall", context: PaywallContext(placement: "feature_gate"));
  },
  onUnlocked: () {
    showAISuggestions();
  },
);
Feature flags are managed in the Console under Settings > Feature Flags. Toggle a flag and it takes effect on the next SDK config refresh (default 5 minutes).