FirebaseRtdbChannel class

Firebase Realtime Database implementation of RealtimeChannel.

Incoming messages are received via DatabaseReference.onChildAdded, outgoing messages are written via DatabaseReference.push. Connection status is derived from the Firebase .info/connected special path, so it reflects true connectivity (including offline persistence).

final channel = FirebaseRtdbChannel(
  channelId: 'room1',
  path: 'channels/room1/messages',
);
await channel.connect();
channel.messages.listen((msg) => print(msg.payload));
await channel.send({'text': 'hello'}, type: 'chat');
Implemented types

Constructors

FirebaseRtdbChannel({required String channelId, required String path, FirebaseDatabase? database, int maxMessages = 100})
Creates a FirebaseRtdbChannel.

Properties

channelId String
The unique identifier for this channel.
final
hashCode int
The hash code for this object.
no setterinherited
isConnected bool
Whether the channel is currently connected.
no setteroverride
messages Stream<RealtimeMessage>
Stream of messages received on this channel.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status Stream<ChannelStatus>
Stream of connection status changes.
no setteroverride

Methods

connect() Future<void>
Establishes the connection to the backend.
override
disconnect() Future<void>
Gracefully closes the connection.
override
dispose() Future<void>
Releases all resources.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(Map<String, dynamic> payload, {String? type}) Future<void>
Sends payload to the channel.
override
toString() String
A string representation of this object.
inherited

Operators

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