sse_request library

Classes

SseParsedSourceController<T>
Implementation of SseSourceControllerBase where the onErrorEvent and eventParser action can be specified in parameter, allowing configuration of reconnection logic and parsing of each event into a specified object type.
SseRequest
An HTTP request where the entire request body is known in advance.
SseSourceController
Implementation of SseSourceControllerBase where the onErrorEvent action can be specified in parameter, allowing configuration of reconnection logic.
SseSourceControllerBase<T>
Base class for SSE source controllers. Manages connection lifecycle and event handling. Sets up the event stream controller with custom onListen and onCancel.
StreamSourceController<T>
Isolation wrapper for StreamController with dispose

Functions

sseRequestGetSendStreamed({required Uri uri, Client? client, Map<String, String>? headers, Encoding? encoding}) Future<Stream<Map<String, dynamic>>>
Sends the GET request with the specified URI, headers, and encoding. Transforms ByteStream to Map<String, dynamic> for every event.
sseRequestGetStream({required Uri uri, required String subName, Map<String, String>? headers, Encoding? encoding}) Stream<Map<String, dynamic>>
Creates an SSE GET request with the specified URI, headers and encoding.
sseRequestPostSendStreamed({required Uri uri, Client? client, Map<String, String>? headers, Map<String, dynamic>? body, Encoding? encoding}) Future<Stream<Map<String, dynamic>>>
Sends the GET request with the specified URI, headers, body, and encoding. Transforms ByteStream to Map<String, dynamic> for every event.
sseRequestPostStream({required Uri uri, required String subName, Map<String, String>? headers, Map<String, dynamic>? body, Encoding? encoding}) Stream<Map<String, dynamic>>
Sends the POST request with the specified URI, headers, body, and encoding.

Typedefs

ConnectionStreamBuilder = FutureOr<Stream<Map<String, dynamic>>> Function(Client client)
EventErrorAction = FutureOr<void> Function(SseSourceController controller, Object error, StackTrace stackTrace)
ParsedEventErrorAction = FutureOr<void> Function(SseParsedSourceController controller, Object error, StackTrace stackTrace, [Map<String, dynamic>? sourceEvent])