Skip to content

app_debugger_feature_flag Pro

Feature flag spoofer sub-brick for app_debugger. Adds a Feature Flags tab to the debugger panel that lets developers override flag evaluations at runtime without touching the real provider chain. Automatically swapped to a no-op stub in release builds.

Version: 1.0.0

Variables

This brick has no generation-time variables. The spoofer delegate works with any FeatureFlagProvider implementation at runtime.

Prerequisites

  • app_debugger brick must be installed first.
  • A feature_flag_impl package must be configured in your app.

Usage

Interactive

bash
archipelago generate app_debugger_feature_flag

Non-interactive (CI)

bash
archipelago generate app_debugger_feature_flag --config my_config.json

Generated Structure

features/
└── app_debugger_feature_flag/
    ├── app_debugger_feature_flag_api/
    │   └── lib/src/
    ├── app_debugger_feature_flag/
    │   └── lib/src/
    └── app_debugger_feature_flag_noop/
        └── lib/src/

Required Setup After Generation

Wire the delegate into your FeatureFlag SDK's delegate chain (in post_launch_initializer.dart or your DI setup):

dart
final spoofer = getIt<FeatureFlagSpooferSDK>();
if (spoofer.delegate != null) {
  featureFlagSdk.addDelegate(spoofer.delegate!);
}

The null guard makes this safe in release builds where the noop stub returns null for delegate.

Delegate Chain Semantics

FeatureFlagDelegate is an override hook that runs before the real provider chain. Multiple delegates can be chained; the aggregator iterates them and stops at the first non-null result.

The spoofer installs itself at the front of the delegate chain so its overrides always take precedence.

FlagOverride Model

FieldTypeDescription
flagKeyStringThe flag key to override
valueFeatureFlagResultThe result returned when the override is active
enabledbool (default: true)Toggle the override on/off without removing it

Setting enabled: false suspends the override without deleting it — useful for temporarily restoring real-provider behaviour for a specific flag during testing.

How It Works

  1. FeatureFlagSpooferSDKImpl constructs a FeatureFlagSpooferDelegate backed by a shared Map<String, FlagOverride> and registers a FeatureFlagSpooferPage with DebuggerPanelPageRegistry.
  2. DebuggerPanel reads DebuggerPanelPageRegistry.instance.pages and appends extra tabs — no import of app_debugger_feature_flag required.
  3. FeatureFlagSpooferDelegate.evaluate checks the override map for the flag key — if an enabled override exists, returns override.value; otherwise returns null, deferring to the next delegate.
  4. build_prepare.yaml swaps app_debugger_feature_flagapp_debugger_feature_flag_noop for release builds.

Built by Banua Coder