toCode method

  1. @override
List<String> toCode()
override

Implementation

@override
List<String> toCode() {
  var _lines = super.toCode();

  var argsLine = args?.map((arg) => '${arg.toString()}').join(', ') ?? '';

  var callLine = '';

  callLine += '$name($argsLine)';

  if (isAsync) {
    callLine += ' async ';
  }

  var body = '';
  bodyCodeParts?.forEach((codePart) {
    body += codePart.toString();
  });

  callLine = '$callLine { $body }';

  if (outputType != null) {
    callLine = variableTypeToString(outputType!) + ' ' + callLine;
  }

  if (annotations != null) {
    annotations!.forEach((annotation) {
      callLine = '@$annotation\n' + callLine;
    });
  }

  _lines.add(callLine);
  return _lines;
}