FeatureFlag class

A single runtime-toggleable value, registered by the host app and flipped from the Flags tab without a rebuild.

Listen to notifier directly wherever the app needs to react to changes:

final flag = FeatureFlagStore.register(FeatureFlag(
  key: 'new_checkout_flow',
  label: 'New Checkout Flow',
  type: FeatureFlagType.boolean,
  defaultValue: false,
));

ValueListenableBuilder(
  valueListenable: flag.notifier,
  builder: (_, enabled, __) => (enabled as bool) ? NewCheckout() : OldCheckout(),
);

Constructors

FeatureFlag({required String key, required String label, required FeatureFlagType type, required Object defaultValue, List<Object>? options})
Creates a flag. defaultValue's runtime type should match type (bool for FeatureFlagType.boolean, num for FeatureFlagType.number, String for FeatureFlagType.string and FeatureFlagType.options). options is required and must be non-empty when type is FeatureFlagType.options.

Properties

defaultValue → Object
Restored by reset and by the tab's "reset all" action.
final
hashCode → int
The hash code for this object.
no setterinherited
key → String
Stable identifier. Also what the app looks the flag up by via FeatureFlagStore.get.
final
label → String
Shown in the Flags tab in place of key.
final
notifier → ValueNotifier<Object>
The flag's current value. Listen to this directly to react to changes without rebuilding on every other flag's update.
final
options → List<Object>?
Required, and must be non-empty, when type is FeatureFlagType.options.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
type → FeatureFlagType
How this flag's value is presented and edited in the Flags tab.
final
value ↔ Object
Shorthand for notifier.value.
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Restores value to defaultValue.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited