Skip to main content
Version: 3.x.x

Leave or End Meeting - Flutter

Participant can choose to leave the meeting without removing all the other participants. This is typically done by Leave Meeting.

Alternatively, if the participant is the host or the last person remaining in the session, they can choose End Meeting by removing all other participants, which will end the session for everyone.

leave()

To leave the meeting without removing all the participant you need to call leave() on the Room object.

end()

To leave the meeting by removing all the participant you need to call end() on the Room object.

Example

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

class MeetingScreen extends StatefulWidget {
...
}

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

@override
void initState() {
...
}

@override
Widget build(BuildContext context) {
return Column(
children:[
ElevatedButton(
onPressed:(){
_room.leave();
},
child: const Text("Leave Meeting"),
),
ElevatedButton(
onPressed:(){
_room.end();
},
child: const Text("End Meeting"),
),
]
);
}
}
tip

You should call the leave() method on the unmount of your main meeting widget so that meeting is left once the widget is unmounted.

Events associated with Leave

Following callbacks are received when a participant leaves the meeting.

Events associated with End

Following callbacks are received when a participant ends the meeting.

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

class MeetingScreen extends StatefulWidget {
...
}

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

@override
void initState() {
...

setupRoomEventListener();
}

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

void setupRoomEventListener() {
room.on(Events.roomLeft, (){
// Room/Meeting left
});
room.on(Events.participantLeft, (String participantId , Map<String,dynamic> reason){
// Participant left the meeting
});
}
}

Participant Left – Reason Codes

  • When Events.participantLeft is triggered, a reason object is also provided.

  • The table below outlines the possible reason codes and their descriptions:

TypeCodeMessage
WEBSOCKET_DISCONNECTED1001Socket disconnected.
REMOVE_PEER1002Participant was removed from the meeting.
REMOVE_PEER_VIEWER_MODE_CHANGED1003Participant removed because viewer mode was changed.
REMOVE_PEER_MEDIA_RELAY_STOP1004Your organization has reached the maximum number of speakers allowed.
SWITCH_ROOM1005Participant switched to a different room.
ROOM_CLOSE1006The meeting has been closed.
UNKNOWN1007Participant disconnected due to an unknown reason.
REMOVE_ALL1008Remove All from the meeting.
MEETING_END_API1009Meeting Ended.

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