Flutter realtime
Connect the v1 WebSocket lifecycle, subscribe to channels, process durable events, and handle app lifecycle.
Connection lifecycle
final info = await client.connectRealtime();
renderConnectionId(info.connectionId);
await client.suspendRealtimeIfConnected();
await client.resumeRealtimeIfSuspended();
await client.disconnectRealtime();connectRealtime requires a connected user, obtains a fresh one-use ticket, offers only vchat.realtime.v1, and returns after connection.ready. Automatic reconnect uses fresh authentication and bounded jittered backoff.
Subscribe to a channel
final subscription = await client.subscribeChannel(identity);
final cancelEvents = subscription.onEvent((event) {
renderDurableEvent(event);
});
final cancelPrivate = client.onUserMessagingState((state) {
reconcilePrivateState(state);
});
cancelEvents();
cancelPrivate();
await subscription.unsubscribe();The SDK commits valid typed event state into the exact scoped cache before host callbacks run. Subscriptions remain connection-local and reconnect restoration rechecks authorization.
Pressure and terminal closes
Frames, queues, subscriptions, and in-flight commands are bounded. Protocol/policy, connection-limit, and slow-consumer closes are terminal for the automatic cycle. Correct the consumer, refresh authoritative state, then reconnect explicitly.
Presence and typing
Presence watches replace 1–50 exact users and decay to unknown when freshness expires. Typing supports the channel and one-depth thread contexts, rate-limits keystrokes, and sends an idle stop. Disconnect clears both; recovery restores watches after durable repair but never replays typing.