Room Events - Flutter
VideoSDK provides several types of events that can be listened to in order to determine the current state of the room.
Here are the events specifically related to the room:
Events.roomJoined
- This event is triggered when the room is successfully joined.
- It can be subscribed to using the
Roomobject.
Events.roomLeft
- This event is triggered when the room is left with a specified reason. You can refer to the reason details here.
- It can be subscribed to using the
Roomobject. - After this event the room releases itself and removes every handler. To join again, create a new
Room.
Events.speakerChanged
- This event is triggered when there is a change in the active speaker during the room.
- It can be subscribed to using the
Roomobject. - The handler receives the id of the active speaker, or
nullwhen no one is speaking. room.getActiveSpeakerId()returns the latest one.
Events.presenterChanged
- This event is triggered when there is a change in the presenter during the room.
- It can be subscribed to using the
Roomobject. - The handler receives the id of the presenter, or
nullwhen no one is sharing their screen. room.getActivePresenterId()returns the latest one.
Phone call events
Events.externalCallRinging,Events.externalCallAnswered,Events.externalCallRejectedandEvents.externalCallHanguptell you when a phone call rings, is answered, is declined or ends on this device during the room.- Each handler receives a
CallType?:CallType.INCOMINGorCallType.OUTGOING. - Android cannot tell a declined call from a missed one, so it reports both as
externalCallRejected.
Example
Here is an example demonstrating the usage of all the events mentioned on this page.
import 'package:flutter/material.dart';
import 'package:videosdk/videosdk.dart';
class RoomScreen extends StatefulWidget {
//Existing configuration
}
class _RoomScreenState extends State<RoomScreen> {
late Room room;
@override
void initState() {
super.initState();
//Existing configuration
setupRoomEventListener();
}
@override
Widget build(BuildContext context) {
return YourRoomWidget();
}
void setupRoomEventListener() {
room.on(Events.roomJoined, () {
//Room Joined successfully
});
room.on(Events.externalCallRinging, (CallType? callType) {
//A phone call is ringing. You may want to mute the mic.
});
room.on(Events.roomLeft, (LeaveReason? reason) {
//Room Left
if(reason != null){
print("Room Left reason: ${reason.message} and code: ${reason.code}");
}
});
room.on(Events.speakerChanged, (String? activeSpeakerId) {
//Room active speaker has changed
//Participant ID of current active speaker is activeSpeakerId
});
room.on(Events.presenterChanged, (String? presenterId) {
//Room screen presenter has changed
//Participant ID of current presenter is presenterId
});
}
}
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord

