onConnected property

Stream<bool> get onConnected

Whether the client is connected to the server (.info/connected). The first event is the current state.

close (also run when the app is deleted) ends the stream with done and no error; no final false event comes before it.

Each access returns a new multi-listener stream (isBroadcast is false) that replays the current state to a new listener but not earlier changes.

Implementation

Stream<bool> get onConnected => ref(
  '.info/connected',
).onValue.map((DatabaseEvent event) => event.snapshot.value == true);