call method
Invokes an onCall or onCallWithData function by name.
Constructs the standard callable wire format ({"data": ...}) and
the optional Authorization: Bearer <idToken> header automatically.
Returns the raw Shelf Response; use parseCallableResponse to extract the result payload.
Implementation
Future<Response> call(
String name, {
dynamic data,
String? idToken,
Map<String, String>? extraHeaders,
}) {
final headers = <String, String>{
'content-type': 'application/json',
if (idToken != null) 'authorization': 'Bearer $idToken',
...?extraHeaders,
};
final request = Request(
'POST',
Uri.parse('http://localhost/${toCloudRunId(name)}'),
body: jsonEncode({'data': data}),
headers: headers,
);
return _invoke(toCloudRunId(name), request);
}