sourceCode property

String sourceCode
override

Implementation

@override
String get sourceCode {
  if (_sourceCode == null) {
    // We could use a set to figure the dupes out, but that would lose ordering.
    var fieldSourceCode = modelNode.sourceCode ?? '';
    var getterSourceCode = getter?.sourceCode ?? '';
    var setterSourceCode = setter?.sourceCode ?? '';
    var buffer = StringBuffer();
    if (fieldSourceCode.isNotEmpty) {
      fieldSourceCode = _sourceCodeRenderer.renderSourceCode(fieldSourceCode);
      buffer.write(fieldSourceCode);
    }
    if (buffer.isNotEmpty) buffer.write('\n\n');
    if (fieldSourceCode != getterSourceCode) {
      if (getterSourceCode != setterSourceCode) {
        buffer.write(getterSourceCode);
        if (buffer.isNotEmpty) buffer.write('\n\n');
      }
    }
    if (fieldSourceCode != setterSourceCode) {
      buffer.write(setterSourceCode);
    }
    _sourceCode = buffer.toString();
  }
  return _sourceCode;
}