Dart: Realtime
Join channels, send and receive messages, follow connection status and catch up after a reconnect with the Dart and Flutter SDK.
Join channels, send and receive messages, follow connection status and catch up after a reconnect. Every call runs as the client's signed-in user, so your project's policies and row-level security apply. Types and members are listed in source order; each one links to its HTTP endpoint where it maps to one.
#Types and members
WebSocketConnector
Opens a WebSocket (swap it in tests).
typedef WebSocketConnectorRealtimeStatus
enum RealtimeStatusValues: connecting, live, reconnecting, closed.
SovariaRealtime
Realtime channels: final ch = sovaria.realtime.channel('room:42'); ch.messages.listen(...). Each connection uses a one-time ticket (the token never goes in the URL); the channel reconnects with backoff and stops when the user is signed out or not allowed.
class SovariaRealtimeSovariaRealtime.SovariaRealtime
Create an instance.
SovariaRealtime(this._client, {WebSocketConnector? connector})
: _connectorSovariaRealtime.channel
catchUp: after a reconnect, deliver the messages published while the socket was down (from the channel's replay history) — in order, once each — before new ones.
RealtimeChannel channel(String name, {Duration maxBackoff = const Duration(seconds: 15), bool catchUp = true})SovariaRealtime.publish
Publish to a channel over HTTP (no socket needed).
Future<void> publish(String channel, Map<String, Object?> payload)SovariaRealtime.replay
Messages after after (by stream_seq), oldest first: {events: [...]}.
Future<dynamic> replay(String channel, {int after = 0, int limit = 200})SovariaRealtime.presence
Who is in a channel right now.
Future<dynamic> presence(String channel)SovariaRealtime.closeAll
Future<void> closeAll()RealtimeChannel
class RealtimeChannelRealtimeChannel.name
A property.
final String nameRealtimeChannel.status
A property.
RealtimeStatus statusRealtimeChannel.messages
Message payloads (frame.payload, pings filtered out).
Stream<Map<String, Object?>> get messagesRealtimeChannel.statusChanges
A property.
Stream<RealtimeStatus> get statusChangesRealtimeChannel.errors
A property.
Stream<Object> get errorsRealtimeChannel.gaps
Messages that were missed and can't be recovered (older than the channel's retained history, or the history couldn't be read).
Stream<RealtimeGap> get gapsReload your state from the source of truth when one arrives.
RealtimeChannel.send
Publish a message to everyone on the channel.
Future<void> send(Map<String, Object?> payload)RealtimeChannel.close
Future<void> close()RealtimeGap
Messages fromSeq..toSeq (by stream_seq) were missed and can't be recovered; toSeq is null when the history couldn't be read. reason: not_retained or replay_failed.
class RealtimeGapRealtimeGap.RealtimeGap
Create an instance.
const RealtimeGap(this.fromSeq, this.toSeq, this.reason)RealtimeGap.fromSeq
A property.
final int fromSeqRealtimeGap.toSeq
A property.
final int? toSeqRealtimeGap.reason
A property.
final String reasonRealtimeGap.toString
String toString()