VariableScope class
An immutable set of runtime variables a surface is rendered against, with convenience methods for interpolating a single string.
Constructors
-
VariableScope(Map<
String, dynamic> variables, [Map<String, String> types = const {}]) -
const
-
VariableScope.fromSchemas(List<
VariableSchema> schemas, Map<String, dynamic> ? cepVars) -
Builds a scope by resolving each declared
schemasentry against the runtimecepVarspayload. The winning value follows the chain payload →fallbackValue→""; number-typed variables are coerced numerically so they can take part in{{ a + b }}arithmetic. Custom and context variables (user.age) resolve the same way.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
types
→ Map<
String, String> -
Type map for arithmetic:
"number"entries participate in arithmetic expressions; everything else is plain-substitution only.final -
variables
→ Map<
String, dynamic> -
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
String text) → String -
Replaces every
{{ … }}token intext. A bare variable name ({{ coupon }},{{ user.age }}) is a direct lookup; anything else is evaluated as an arithmetic expression over the scope's number-typed variables (collapsing to""on any error). -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
reportMissing(
List< VariableSchema> schemas, Map<String, dynamic> ? cepVars, String campaignKey) → void -
Logs each declared variable with no CEP value and no fallback for
campaignKey. Call it where the campaign is known, never from a build. -
reportTypeMismatches(
List< VariableSchema> schemas, Map<String, dynamic> ? cepVars, String campaignKey) → void -
Reports once, as a
variable_type_mismatchhealth event, every declared variable whose CEP value does not fit its declared type (at most maxMismatches, each sample shortened to maxSampleLength). Call it where the campaign is known, never from a build. -
truncatedMismatchSample(
String sample) → String - Shortens a mismatch sample to at most maxSampleLength code points: first part + "…" + last part (16 + 1 + 15). A cut never lands inside a grapheme cluster, so it may come out shorter. iOS and Android apply the same rule; the shared sample table in the tests pins all three.
Constants
- empty → const VariableScope
- No variables in scope — every placeholder collapses to empty.
- maxMismatches → const int
- maxSampleLength → const int