setValue method
Stores value in the property, variable or element the expression
names, such as user.name, #count or items[0].
This is how data binding writes a form field addressed by a path. A
null rootObject means the context's root; a null context a
new StandardEvaluationContext.
final data = {'count': 1};
parser.parseExpression('count').setValue(null, data, 2);
// data == {'count': 2}
Throws a SpelEvaluationException (notAssignable) when the target
is not assignable (a literal, a template) or the context disables
assignment.
Implementation
@override
void setValue(EvaluationContext? context, Object? rootObject, Object? value) {
final state = _state(context, rootObject);
if (!state.context.isAssignmentEnabled) {
throw SpelEvaluationException(
SpelMessage.notAssignable,
inserts: [expressionString],
expressionString: expressionString,
);
}
_run(state, () => ast.assign(state, () => value));
}