SSEConnection class

SSE 连接封装类 自动管理订阅和资源清理,简化使用

Properties

events Stream<SSEEvent>
事件流(只读)
no setter
hashCode int
The hash code for this object.
no setterinherited
isConnected bool
连接状态
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelListen() → void
取消监听(但不断开连接)
disconnect() Future<void>
断开连接并清理资源
listen({required void onData(SSEEvent event), void onError(Object error)?, void onDone()?}) SSEConnection
监听事件(自动管理订阅)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

connect({required String baseUrl, required String path, String method = 'GET', dynamic data, Map<String, String>? queryParameters, Map<String, String>? staticHeaders, Future<Map<String, String>> dynamicHeaderBuilder()?, Map<String, String>? headers}) Future<SSEConnection>
创建并连接 SSE