InvergeDocs
FlutterAPI reference

Realtime

Realtime in the Flutter SDK.

import 'package:nexus_flutter/nexus.dart';
SymbolKindSummary
NexusEventHandlertypedef
NexusRealtimeclassRealtime messaging over Socket.IO.

NexusEventHandler

typedef
typedef NexusEventHandler = void Function(dynamic data)
View source

NexusRealtime

class

Realtime messaging over Socket.IO. Authenticates with the API key + the current journey identity, so realtime connections join the same session.

View source

isConnected

property
bool get isConnected
View source

isActive

property
bool get isActive

Whether a socket exists (connected, or connecting/reconnecting) — i.e. the app wants realtime up, even if the link is momentarily down.

View source

connect()

method
void connect()

Open the connection (idempotent). Rooms are re-joined after a reconnect.

View source

join()

method
Future<dynamic> join(String room)

Join a room (first/created on the server). Re-joined automatically on reconnect. Returns the server's acknowledgement ({ ok, room, related }).

Parameters

Prop

Type

Returns Future<dynamic>

View source

leave()

method
Future<dynamic> leave(String room)

Leave a room. Returns the server's acknowledgement ({ ok }).

Parameters

Prop

Type

Returns Future<dynamic>

View source

emit()

method
Future<dynamic> emit(String room, dynamic event, [Object? payload])

Emit one or more named events to a room with a payload. Returns the server's acknowledgement ({ ok, room, recipients, related } or { error }), which is also logged.

Parameters

Prop

Type

Returns Future<dynamic>

View source

on()

method
void on(String event, NexusEventHandler handler)

Listen for a server event. Persisted, so it survives (re)connects and works even if called before the socket is open.

Parameters

Prop

Type

View source

off()

method
void off(String event)

Stop listening for a server event.

Parameters

Prop

Type

View source

disconnect()

method
void disconnect()
View source

On this page