Skip to main content

Cloud Functions

callFunction​

Future<FunctionResponse> app.callFunction({
required String name,
FunctionType type = FunctionType.function,
Map<String, dynamic>? data,
HttpMethod method = HttpMethod.post,
String path = '/',
Map<String, String>? header,
bool parse = true,
})

Call cloud function. Supports both basic cloud functions and function-type cloud run.

Parameters

name
String

Function/service name

type
FunctionType

Call type: FunctionType.function (default) / FunctionType.cloudrun

data
Map<String, dynamic>?

Request data

method
HttpMethod

HTTP method (only valid for cloudrun type, default POST)

path
String

HTTP path (only valid for cloudrun type, default /)

header
Map<String, String>?

HTTP headers (only valid for cloudrun type)

parse
bool

Whether to parse return object (only valid for function type, default true)

Response

Future
FunctionResponse

Example

final result = await app.callFunction(
name: 'myFunction',
data: {'action': 'getUserList', 'pageSize': 10},
);

if (result.isSuccess) {
print('Execution result: ${result.result}');
} else {
print('Execution failed: ${result.message}');
}