Skip to main content
Version: 1.1.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){
// Participant left the meeting
});
}
}

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