isEnabled method
Provider short-circuit, then static set membership, then gate evaluation (SC-003).
Implementation
bool isEnabled(String name) {
final context = _currentContext(name);
// 1. Pluggable whole-feature provider (US6) — its answer wins; a
// throw or a null answer falls back to the static path (FR-010).
final provider = _provider;
if (provider != null) {
try {
final answer = provider.isEnabled(name, context);
if (answer != null) return answer;
} catch (_) {
// fail-safe: fall through to build-time defaults
}
}
// 2. Build-time static default: a feature disabled at build time is
// disabled, period. Unknown names are disabled too (US3.AC4).
if (!_enabled.contains(name)) return false;
// 3. Gates: ALL must pass (US4.AC5). Any failing/unavailable gate
// fails closed.
final gates = _gates[name];
if (gates == null || gates.isEmpty) return true;
for (final gate in gates) {
if (!_gateSatisfied(name, gate, context)) return false;
}
return true;
}