Remove Participant - Flutter
When hosting a live stream, it's essential for the host to have the capability to to remove a participant from the live stream. This can be useful in various scenarios where a participant is causing disturbance, behaving inappropriately, or is not following the guidelines. This guide focuses on this very aspect of removing a particpant from the live stream.
VideoSDK provides three ways to do so:
1. Using SDK​
remove()
​
The remove()
method allows for the removal of a participant during an on-going session. This can be helpful when moderation is required in a particular live stream.
Events associated with remove​
Following callbacks are received when a participant is removed from the Livestream.
- Participant who was removed from the Livestream will receive a callback on
roomLeft
onRoom
object. - All other remote participants will receive a callback
participantLeft
withparticipantId
.
import 'package:flutter/material.dart';
import 'package:videosdk/videosdk.dart';
class ParticipantTile extends StatefulWidget {
final Participant participant;
const ParticipantTile({super.key, required this.participant});
@override
State<ParticipantTile> createState() => _ParticipantTileState();
}
class _ParticipantTileState extends State<ParticipantTile> {
@override
Widget build(BuildContext context) {
return ElevatedButton(
child: Text("Remove ${widget.participant.displayName}"),
onPressed: () => {
widget.participant.remove();
});
}
}
2. Using VideoSDK Dashboard​
- For removing a participant using the VideoSDK Dashboard, navigate to the session page on VideoSDK Dashboard. Select the specific session, and from the list of participants, choose the participant you wish to remove. Utilize the provided options to remove the selected participant from the session.
3. Using Rest API​
- You can also remove a particular participant from the live stream using the REST API.
- To employ this method, you need the
sessionId
of the live stream and theparticipantId
of the individual you intend to remove.
API Reference​
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord