BloomFeatureFlags class
Dynamic, signal-backed feature flags engine for runtime gating and progressive rollout.
BloomFeatureFlags allows defining, evaluating, and observing boolean feature flags.
Each registered flag is backed by a reactive Signal, meaning components observing a flag
via watch or Show automatically re-render when the flag value is toggled or overridden.
Flag Evaluation & Precedence
- If an explicit override or runtime state has been assigned via setOverride, register, or registerAll, the current signal value is used.
- If the requested flag has never been registered or watched, the query method falls back
to the supplied
defaultValue. - Calling clearOverrides resets all active signals back to their registered default values.
Backend Behavior
- Browser (
mount): SubscribedLiveandShowdescriptors react dynamically when flags change via setOverride or registerAll. - SSR (
renderToHtml): Flag evaluations via isEnabled or watch run synchronously during HTML generation. SSR renders the branch according to the flag's initial state.
Example
final features = BloomFeatureFlags();
// Register feature flags with default values
features.registerAll({
'new_dashboard': true,
'beta_export': false,
});
// Conditionally render in UI
BloomNode buildHeader() {
return Div(
children: [
Show(
() => features.watch('beta_export').value,
child: Button(text: 'Export (Beta)'),
),
],
);
}
// Dynamically toggle at runtime (e.g. from an admin panel or remote config)
features.setOverride('beta_export', true);
Constructors
- BloomFeatureFlags()
- Creates a new, isolated BloomFeatureFlags engine.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearOverrides(
) → void - Restores all registered feature flags to their original default values.
-
getAll(
) → Map< String, bool> - Returns an immutable snapshot map of all registered flag names and their current boolean states.
-
isEnabled(
String flagName, {bool defaultValue = false}) → bool -
Synchronously checks whether
flagNameis currently enabled. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register(
String flagName, {bool defaultValue = false}) → void - Registers a feature flag with its default boolean state.
-
registerAll(
Map< String, dynamic> flags) → void - Registers multiple feature flags simultaneously from a map.
-
reset(
) → void - Resets the engine by removing all flags, signals, and defaults.
-
setOverride(
String flagName, bool value) → void -
Sets or overrides the runtime boolean state of
flagName. -
toString(
) → String -
A string representation of this object.
inherited
-
watch(
String flagName, {bool defaultValue = false}) → ReadonlySignal< bool> -
Returns a reactive ReadonlySignal tracking the boolean state of
flagName.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited