Skip to main content
Version: 1.2.x

Room Connection Events - Flutter

VideoSDK provides Events.roomStateChanged event which will notify you of the current connection state of the room.

Events.roomStateChanged​

  • This event is triggered whenever the room's state changes.
  • The current state of the room is passed as a callback parameter.
  • All available states are connecting, connected, failed, disconnected, closing, closed.
  • It can be subscribed to using the Room object.

Example​

Here is the usage of the event mentioned in this page.

import 'package:flutter/material.dart';
import 'package:videosdk/videosdk.dart';

class MeetingScreen extends StatefulWidget {
//Existing configuration
}

class _MeetingScreenState extends State<MeetingScreen> {
late Room room;

@override
void initState() {
//Existing configuration

setupRoomEventListener();
}

@override
Widget build(BuildContext context) {
return YourMeetingWidget();
}

void setupRoomEventListener() {
room.on(Events.roomStateChanged, (RoomState state) {
switch (state) {
case RoomState.connecting:
print('Meeting is Connecting');
break;
case RoomState.connected:
print('Meeting is Connected');
break;
case RoomState.disconnected:
print('Meeting connection disconnected abruptly');
break;
case RoomState.failed:
print('Meeting connection failed');
break;
case RoomState.closing:
print('Meeting is closing');
break;
case RoomState.closed:
print('Meeting connection closed');
break;
default:
print('default');
}
});
}

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