blockly > WorkspaceSvg > createVariable

WorkspaceSvg.createVariable() method

Create a new variable with the given name. Update the flyout to show the new variable immediately.


createVariable(name: string, opt_type?: string | null, opt_id?: string | null): VariableModel;


Parameter Type Description
name string The new variable's name.
opt_type string | null (Optional) The type of the variable like 'int' or 'string'. Does not need to be unique. Field_variable can filter variables based on their type. This will default to '' which is a specific type.
opt_id string | null (Optional) The unique ID of the variable. This will default to a UUID.



The newly created variable.