VariableScope.fromSchemas constructor

VariableScope.fromSchemas(
  1. List<VariableSchema> schemas,
  2. Map<String, dynamic>? cepVars
)

Builds a scope by resolving each declared schemas entry against the runtime cepVars payload. 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.

Implementation

factory VariableScope.fromSchemas(
  List<VariableSchema> schemas,
  Map<String, dynamic>? cepVars,
) {
  final values = <String, dynamic>{};
  final types = <String, String>{};
  for (final schema in schemas) {
    types[schema.name] = schema.type;
    values[schema.name] = schema.resolve(cepVars?[schema.name]);
  }
  return VariableScope(values, types);
}