RemoteAction<O, S> constructor

RemoteAction<O, S>({
  1. required String url,
  2. Map<String, String>? defaultHeaders,
  3. Client? httpClient,
  4. required O fromResponse(
    1. dynamic jsonData
    ),
  5. S fromStreamChunk(
    1. dynamic jsonData
    )?,
})

Represents a remote Genkit action (flow) that can be invoked or streamed.

This class is typically instantiated via defineRemoteAction. It encapsulates the URL, default headers, HTTP client, and data conversion logic for a specific flow.

Type parameters:

  • O: The type of the output data from a non-streaming flow invocation, or the type of the final response from a streaming flow.
  • S: The type of the data chunks streamed from the flow.

Implementation

RemoteAction({
  required String url,
  Map<String, String>? defaultHeaders,
  http.Client? httpClient,
  required O Function(dynamic jsonData) fromResponse,
  S Function(dynamic jsonData)? fromStreamChunk,
}) : _url = url,
     _defaultHeaders = defaultHeaders,
     _httpClient = httpClient ?? http.Client(),
     _ownsHttpClient = httpClient == null,
     _fromResponse = fromResponse,
     _fromStreamChunk = fromStreamChunk;