extractProtoMethodParams function

String extractProtoMethodParams(
  1. String filePath,
  2. String methodName
)

Implementation

String extractProtoMethodParams(String filePath, String methodName) {
  final content = File(filePath).readAsStringSync();
  final services = parseProtoServices(content);

  for (final service in services) {
    for (final method in service.methods) {
      if (method.name == methodName) {
        final requestType = method.requestType;
        if (requestType == 'void' || requestType == 'google.protobuf.Empty') {
          return '()';
        }

        final type = method.isClientStreaming
            ? 'Stream<$requestType>'
            : requestType;
        return '($type request)';
      }
    }
  }
  return '()';
}