isEnabled method

bool isEnabled(
  1. String flagName, {
  2. bool defaultValue = false,
})

Synchronously checks whether flagName is currently enabled.

Returns the current value of the flag if registered or previously observed. If the flag is unregistered and has never been watched, returns defaultValue (defaults to false). This is a one-shot read and does NOT subscribe to reactive signal updates unless called inside an active signal tracking context.

if (features.isEnabled('dark_mode_v2')) {
  enableDarkModeV2();
}

Implementation

bool isEnabled(String flagName, {bool defaultValue = false}) {
  if (_flags.containsKey(flagName)) {
    return _flags[flagName]!.value;
  }
  return defaultValue;
}