createSignature function
Method
createSignature(
- ClientMethod method, {
- Code? body,
})
Implementation
Method createSignature(ClientMethod method, {Code? body}) {
final returnType = method.returnType.typeForClient;
return Method(
(b) => b
..name = method.name
..returns = createReturnType(returnType)
..optionalParameters.addAll(getPathParams(method.params))
..optionalParameters.addAll(getParameters(method.allParams, method))
..modifier = switch (returnType) {
ClientType(isStream: true) => MethodModifier.asyncStar,
ClientType(isFuture: true, method: ClientMethod(isWebsocket: true)) =>
MethodModifier.asyncStar,
_ when body == null => null,
_ => MethodModifier.async,
}
..annotations.addAll([if (body != null) refer('override')])
..body = body,
);
}