DVFlags class final

The flag runtime: the synced rules, the evaluation context, and resolution.

Constructors

DVFlags()
@DVFlags() marks the private class a build generates Flags from. The same name as the runtime on purpose: the declaration and the thing that answers for it are one concept.
const

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

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

Operators

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

Static Properties

changes → Stream<void>
Fires when the rule set changes, so a signal over a flag can rebuild.
no setter
context ↔ DVFlagContext Function()
The evaluation context for reads that do not pass one.
getter/setter pair
debugOverrides → Map<String, Object?>
Overrides in force for every read in this process, keyed by flag.
no setter
declared → List<DVFeatureFlag<Object?>>
Every declared flag.
no setter
exposureConsent ↔ bool Function()?
Whether exposure may be recorded. When it answers false nothing is recorded and DV-FLAGS-007 says the experiment is missing people.
getter/setter pair
maxAge ↔ Duration?
Past this age a synced rule set is reported on every resolve — and still used. Stale rules are not discarded: a kill switch that expires back to "on" for the devices hardest to reach is worse than one a day old.
getter/setter pair
onDiagnostic ↔ void Function(String code, String message)
Where diagnostics go. Logged at the registry's level by default.
getter/setter pair
onExposure ↔ void Function(DVFlagExposure exposure)?
Receives each exposure, once per flag per context per session.
getter/setter pair
overridesAllowed → bool
Whether overrides are read at all: false in a release build, where neither kind has a path to an answer.
no setter
overridesInForce → Map<String, Object?>
The overrides a read in this zone is answered with: the process-wide debug overrides, under whatever withOverrides put in force here.
no setter
rules → DVFlagRules?
The rule set in force, or null before the first sync.
no setter
rulesReceivedAt → DateTime?
When rules arrived.
no setter

Static Methods

clearDebugOverride(DVFeatureFlag<Object?> flag) → void
Removes the process-wide override on flag, if there is one.
declare(Iterable<DVFeatureFlag<Object?>> flags) → void
Registers the flags this build declares. The generated accessors call it, which is how a rule set naming an unknown flag gets noticed and how dartvel flags prune knows what is due.
evaluate<T>(DVFeatureFlag<T> flag, DVFlagRules? rules, DVFlagContext context, {Map<String, Object?> overrides = const <String, Object?>{}, bool allowOverrides = true}) → DVFlagResolution<T>
The pure evaluation: an override if allowed, then the first rule that admits context, then the compiled default.
expired(DateTime now) → List<DVFeatureFlag<Object?>>
Declared flags past their expiry at now, in declaration order.
peek<T>(DVFeatureFlag<T> flag, {DVFlagContext? context}) → DVFlagResolution<T>
The answer resolve would give flag now, with nothing recorded.
resetForTest() → void
Clears every piece of process state, for tests.
resolve<T>(DVFeatureFlag<T> flag, {DVFlagContext? context, DateTime? now}) → DVFlagResolution<T>
The answer for flag, reported, pinned and exposed as the spec says.
setDebugOverride<T>(DVFeatureFlag<T> flag, T value) → void
Makes flag answer value for every read in this process, until clearDebugOverride — for a developer trying a branch in a running debug build, where withOverrides reaches only its own callback.
setRules(DVFlagRules? rules, {DateTime? receivedAt}) → void
Installs a synced rule set.
withOverrides<R>(Map<String, Object?> overrides, Future<R> body()) → Future<R>
Runs body with overrides in force for it and for nothing else.