create method Null safety

Variable<T> create(
  1. String name,
  2. {T? value,
  3. bool? constant}

Create a new variable within this scope.

You may optionally provide a value, or mark the variable as constant.


Variable<T> create(String name, {T? value, bool? constant}) {
  // Check if it exists first.
  if (_variables.any((v) => == name)) {
    throw StateError(
        'A symbol named "$name" already exists within the current context.');

  var v = Variable<T>._(name, this, value: value);
  if (constant == true) v.lock();
  return v;