EvaluationContext class
Canonical evaluation context with optional legacy targeting helpers. Use EvaluationContext.immutable to snapshot caller-owned data immediately.
Constructors
-
EvaluationContext({String? targetingKey, required Map<
String, dynamic> attributes, EvaluationContext? parent, List<TargetingRule> rules = const [], Duration cacheDuration = const Duration(minutes: 5)}) -
Legacy const-compatible construction, retaining caller-owned values.
Use EvaluationContext.immutable to opt into deep snapshot semantics.
const
-
EvaluationContext.immutable({String? targetingKey, Map<
String, dynamic> attributes = const {}, EvaluationContext? parent, List<TargetingRule> rules = const [], Duration cacheDuration = const Duration(minutes: 5)}) -
Copies and freezes evaluation fields, including nested maps/lists.
Rule operands outside maps/lists are retained by reference; callers must
keep custom mutable operands stable for the lifetime of the snapshot.
The map-form
targetingKeyis a compatibility alias fortargetingKey; an explicit argument takes precedence at the same context level.factory
Properties
-
attributes
→ Map<
String, dynamic> -
final
- cacheDuration → Duration
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- parent → EvaluationContext?
-
final
-
rules
→ List<
TargetingRule> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- targetingKey → String?
-
final
Methods
-
createChild(
Map< String, dynamic> childAttributes, {String? childTargetingKey, List<TargetingRule> ? childRules, Duration? childCacheDuration}) → EvaluationContext - Create a child context
-
evaluateRules(
) → Future< bool> - Evaluate all targeting rules with caching
-
getAttribute(
String key) → dynamic - Get an attribute value, checking parent context if not found
-
merge(
EvaluationContext other) → EvaluationContext - Create a new context by merging with another Explicit keys precede map aliases and inherited keys; the right explicit key wins over the left explicit key. SDK context levels are merged separately in API -> transaction -> client -> invocation order. Mixing in a legacy context retains legacy semantics.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
snapshot(
) → EvaluationContext - Captures a legacy context and its complete parent chain for SDK use.
-
toProviderContext(
) → Map< String, dynamic> - Return the complete context in the legacy provider-map representation.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited