generateMethod method

void generateMethod(
  1. IndentingWriter out,
  2. MethodDescriptorProto m
)

Implementation

void generateMethod(IndentingWriter out, MethodDescriptorProto m) {
  final methodName = disambiguateName(
      avoidInitialUnderscore(service._methodName(m.name)),
      usedMethodNames,
      defaultSuffixes());
  final inputType = service._getDartClassName(m.inputType, forMainFile: true);
  final outputType =
      service._getDartClassName(m.outputType, forMainFile: true);
  out.addBlock(
      '$asyncImportPrefix.Future<$outputType> $methodName('
          '$protobufImportPrefix.ClientContext? ctx, $inputType request) =>',
      ';', () {
    out.println('_client.invoke<$outputType>(ctx, \'$className\', '
        '\'${m.name}\', request, $outputType())');
  });
}