promoteToClassMember method
void
promoteToClassMember()
If accessed outside of build()
, makes a variable into a class field.
Implementation
void promoteToClassMember() {
if (_visibility == NodeReferenceVisibility.classPublic) {
return;
}
final initialValue = _initialValue;
final hasInitialValue = initialValue != null && initialValue != o.nullExpr;
_visibility = NodeReferenceVisibility.classPublic;
_storage!.allocate(
_name,
outputType: _type,
// All of our NodeReferences are shallowly immutable, that is, they are
// initialized lazily, but the instance does not change after that. If
// we have an initialValue (for example "Text('')"), it is effectively
// final.
modifiers: hasInitialValue
? const [o.StmtModifier.finalStmt]
: const [o.StmtModifier.lateStmt, o.StmtModifier.finalStmt],
initializer: initialValue,
);
}