assignValueToVariable method

void assignValueToVariable(
  1. DartBlockArbiter arbiter,
  2. String variableName,
  3. DartBlockValue? value
)

Assign a value to an existing variable based on its name.

Implementation

void assignValueToVariable(
  DartBlockArbiter arbiter,
  String variableName,
  DartBlockValue? value,
) {
  var containingEnvironment = getContainingEnvironment(variableName);
  if (containingEnvironment != null) {
    containingEnvironment._assignValue(
      arbiter,
      containingEnvironment,
      variableName,
      value,
    );
  } else {
    /// If the variable with the given name is not yet declared, throw an Error.
    throw VariableNotDeclaredException(variableName);
  }
}