Room Class Methods - Flutter
Most Room methods return a Future. When the SDK refuses a call, the Future throws a VideoSDKError with a code, a name and a message, so await each call inside try/catch. A call you do not await turns a refusal into an unhandled error.
- Common codes:
3054when there is nothing to do, for examplemuteMic()on a muted microphone,3055when the same action is already running,3065while the room reconnects, and3035for an action after the room has left. See Room Error Codes for the full list. - On Android, most actions called while the room reconnects report
3065on theerrorevent instead of throwing, so keep anEvents.errorhandler too. - On Android, the SDK never asks for camera or microphone permission, including in
join(),enableCam(),unmuteMic()andchangeMode(). CallVideoSDK.requestPermissions()before you join or turn a device on.
try {
await room.muteMic();
} on VideoSDKError catch (error) {
print("muteMic() failed: ${error.code} ${error.name} ${error.message}");
}
join()
- After creating the instance of VideoSDK Room, you can join VideoSDK Room by calling
join()method. - The returned
Futurecompletes once the room is joined. If the room cannot be joined, it throws aVideoSDKError, for example4002for an invalid token or3073for an empty room id. - A room joins once. After it leaves the room, or if
join()fails,join()throws aStateError. Create a new room withVideoSDK.createRoom()instead. - Calling
join()again on the same room throws aVideoSDKError:3055while the first join is still running, and3054once the room is joined.
Events associated with join():
- Local Participant will receive a
roomJoinedevent, when successfully joined. It can arrive afterjoin()completes, so readlocalParticipantin its handler. - Remote Participant will receive a
participantJoinedevent with the newly joinedParticipantobject from the event handler.
Participant having ask_join permission inside token
-
If a token contains the permission
ask_join, then the participant will not join the room directly after callingjoin(), but an event will be emitted to the participant having the permissionallow_joincalledentryRequested. -
After the decision from the remote participant, an event will be emitted to participant called
entryResponded. This event will contain the decision made by the remote participant. -
While the request waits for a decision,
join()does not complete. Add yourentryRespondedhandler before you calljoin(), or you miss the decision.
Participant having allow_join permission inside token
- If a token containing the permission
allow_join, then the participant will join the room directly after callingjoin().
Returns
Future<void>
Example
// On Android, join() does not ask for camera or microphone permission.
await VideoSDK.requestPermissions();
try {
await room.join();
} on VideoSDKError catch (error) {
// For example 4002 (invalid token) or 3073 (empty room id).
print("Join failed: ${error.code} ${error.name}");
}
leave()
- It is used to leave the current running room session.
- Calling
leave()on a room that has already left the room throws aVideoSDKError. leave()can complete before theroomLeftevent arrives, so close your room screen from theroomLefthandler.- After
roomLeftis delivered, the room removes every handler and releases itself. You do not need to clean it up. To join again, create a new room.
Events associated with leave():
- Local participant will receive a
roomLeftevent. - All remote participants will receive a
participantLeftevent with theParticipantwho left and theLeaveReason.
Returns
Future<void>
Example
try {
await room.leave();
} on VideoSDKError catch (error) {
print("leave() failed: ${error.code} ${error.name}");
}
end()
- It is used to end the current running room session.
- By calling
end(), all joined participants including localParticipant of that session will leave the room.
Events associated with end():
- All participants and localParticipant, will receive
roomLeftevent.
Returns
Future<void>
enableCam()
- It is used to enable camera device.
streamEnabledevent will be emitted on the room with theRTCStreamobject from the event handler. Itsstream.participantIdis the id of the local participant.isCamEnabledistrueonce the call completes.
Parameters
- customCameraTrack:
- type :
CustomStreamTrack - required : false
- A camera track created with
VideoSDK.createCameraVideoTrack(). Without it, the SDK opens its default camera track. - Positional, for example
await room.enableCam(cameraTrack);
- type :
Returns
Future<void>
disableCam()
- It is used to disable camera device.
streamDisabledevent will be emitted on the room with theRTCStreamobject from the event handler.
Returns
Future<void>
unmuteMic()
- It is used to enable microphone device.
streamEnabledevent will be emitted on the room with theRTCStreamobject from the event handler.isMicEnabledistrueonce the call completes.
Parameters
- customMicrophoneTrack:
- type :
CustomStreamTrack - required : false
- A microphone track created with
VideoSDK.createMicrophoneAudioTrack(). Without it, the SDK opens its default microphone track. - Positional, for example
await room.unmuteMic(micTrack);
- type :
Returns
Future<void>
muteMic()
- It is used to disable microphone device.
streamDisabledevent will be emitted on the room with theRTCStreamobject from the event handler.
Returns
Future<void>
enableScreenShare()
- it is used to enable screen-sharing.
streamEnabledevent will be emitted on the room with the screen-shareRTCStreamobject, whosekindisMediaType.SHARE.- presenterChanged will also receive a callback with the
presenterId. - On Android, the user is asked to allow screen capture. On iOS, the system broadcast picker opens, and your app needs a Broadcast Upload Extension, as described in Flutter iOS Screen Share.
Parameters
- customTrack:
- type :
CustomStreamTrack - required : false
- A screen-share track created with
VideoSDK.createScreenShareVideoTrack(). It keeps its own profile. - Without a track, the screen is shared at
CustomScreenShareTrackConfig.h720p_15fps. - To share the device's audio on Android 10 or later, create the track with
withAudio: true. The device audio is sent inside your microphone track, so it is heard only while your microphone is unmuted. iOS screen share sends no audio.
- type :
Returns
Future<void>
Example
// Share at the default profile, without creating a track first
await room.enableScreenShare();
// Or share a track you created
final CustomStreamTrack? shareTrack = await VideoSDK.createScreenShareVideoTrack(
encoderConfig: CustomScreenShareTrackConfig.h720p_15fps,
withAudio: true, // Android only
);
// On Android, null means the user declined the capture prompt.
if (shareTrack != null) {
await room.enableScreenShare(customTrack: shareTrack);
}
disableScreenShare()
- It is used to disable screen-sharing.
streamDisabledevent will be emitted on the room with the screen-shareRTCStreamobject.- presenterChanged will also receive a callback with the
null.
Returns
Future<void>
changeMode()
-
SEND_AND_RECV: The participant sends and receives audio and video. -
SIGNALLING_ONLY: The participant neither sends nor receives audio or video. -
RECV_ONLY: The participant receives audio and video but sends none.
Important Changes Flutter SDK in Version v1.3.0
- The following modes have been deprecated:
CONFERENCEhas been replaced bySEND_AND_RECVVIEWERhas been replaced bySIGNALLING_ONLY
Please update your implementation to use the new modes.
⚠️ Compatibility Notice:
To ensure a seamless meeting experience, all participants must use the same SDK version.
Do not mix version v1.3.0 + with older versions, as it may cause significant conflicts.
participantModeChangedevent will be emitted withparticipantIdandmodeof the participant. Use this event to track each participant's current mode.- On Android, switching to
Mode.SEND_AND_RECVdoes not ask for camera or microphone permission. CallVideoSDK.requestPermissions()first.
Parameters
- mode:
Mode.SEND_AND_RECV|Mode.SIGNALLING_ONLY|Mode.RECV_ONLY
Returns
Future<void>
Example
await room.changeMode(Mode.SEND_AND_RECV);
startRecording()
-
It is used to start room recording.
-
All participants and localParticipant, will receive
recordingStartedevent. -
webhookUrlwill be triggered when the recording is completed and stored into server. Read more about webhooks here.
Parameters
-
webhookUrl:
- type :
String? - required : false
- type :
-
awsDirPath:
- type :
String? - required : false
- type :
-
config:
- type :
RecordingConfig - required : false
- layout:
ConfigLayout- type:
ConfigLayoutGrid.GRID|ConfigLayoutGrid.SPOTLIGHT|ConfigLayoutGrid.SIDEBAR - priority:
ConfigLayoutPriority.SPEAKER|ConfigLayoutPriority.PIN - gridSize:
int`max 4`
- type:
- theme:
ConfigTheme.DARK|ConfigTheme.LIGHT|ConfigTheme.DEFAULT - mode:
ConfigMode.VIDEO_AND_AUDIO|ConfigMode.AUDIO - quality:
ConfigQuality.LOW|ConfigQuality.MED|ConfigQuality.HIGH - orientation:
ConfigOrientation.LANDSCAPE|ConfigOrientation.PORTRAIT - Every field is optional. A field you leave out takes the server's default.
- type :
-
transcription:
- type :
PostTranscriptionConfig - required : false
- enabled:
bool - summary:
SummaryConfig?- enabled:
bool - prompt:
String?
- enabled:
- modelId:
String?
- type :
Returns
Future<void>
Example
const String webhookUrl = "https://webhook.your-api-server.com";
const RecordingConfig config = RecordingConfig(
layout: ConfigLayout(
type: ConfigLayoutGrid.GRID,
priority: ConfigLayoutPriority.SPEAKER,
gridSize: 4,
),
theme: ConfigTheme.LIGHT,
mode: ConfigMode.VIDEO_AND_AUDIO,
);
PostTranscriptionConfig transcription = PostTranscriptionConfig(
enabled: true,
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary",
),
);
await room.startRecording(
webhookUrl: webhookUrl,
config: config,
transcription: transcription,
);
stopRecording()
- It is used to stop room recording.
- All participants and localParticipant, will receive
recordingStoppedevent.
Returns
Future<void>
Example
await room.stopRecording();
startLivestream()
- It is used to start room livestreaming.
- You will be able to start livestream the room to another platforms such as Youtube, Facebook, etc. that supports
rtmpstreaming. - All participants and localParticipant, will receive
livestreamStartedevent.
Parameters
-
outputs:
List<LivestreamOutput>- Each
LivestreamOutputtakes aurland astreamKey.
- Each
-
config:
- type :
LivestreamConfig - required : false
- layout:
ConfigLayout- type:
ConfigLayoutGrid.GRID|ConfigLayoutGrid.SPOTLIGHT|ConfigLayoutGrid.SIDEBAR - priority:
ConfigLayoutPriority.SPEAKER|ConfigLayoutPriority.PIN - gridSize:
int`max 4`
- type:
- theme:
ConfigTheme.DARK|ConfigTheme.LIGHT|ConfigTheme.DEFAULT - recording:
LivestreamRecordingConfig-LivestreamRecordingConfig(enabled: true)also records the livestream.
- type :
Returns
Future<void>
Example
const outputs = [
LivestreamOutput(
url: "rtmp://a.rtmp.youtube.com/live2",
streamKey: "<STREAM_KEY>",
),
LivestreamOutput(url: "rtmps://", streamKey: "<STREAM_KEY>"),
];
const liveStreamConfig = LivestreamConfig(
layout: ConfigLayout(
type: ConfigLayoutGrid.GRID,
priority: ConfigLayoutPriority.SPEAKER,
gridSize: 4,
),
theme: ConfigTheme.LIGHT,
);
await room.startLivestream(outputs, config: liveStreamConfig);
stopLivestream()
- It is used to stop room livestreaming.
- All participants and localParticipant, will receive
livestreamStoppedevent.
Returns
Future<void>
Example
await room.stopLivestream();
startHLS()
- It is used to start HLS.
- All participants and localParticipant, will receive the
hlsStateChangedevent. When its state isHLS_PLAYABLE, it carries anHLSUrlwith theplaybackHlsUrlandlivestreamUrlof the HLS feed.playbackHlsUrl- Live HLS with playback supportlivestreamUrl- Live HLS without playback support
hlsUrlholds the same URLs.
Parameters
-
config:
- type :
HLSConfig - required : false
- layout:
ConfigLayout- type:
ConfigLayoutGrid.GRID|ConfigLayoutGrid.SPOTLIGHT|ConfigLayoutGrid.SIDEBAR - priority:
ConfigLayoutPriority.SPEAKER|ConfigLayoutPriority.PIN - gridSize:
int`max 25`
- type:
- theme:
ConfigTheme.DARK|ConfigTheme.LIGHT|ConfigTheme.DEFAULT - mode:
ConfigMode.VIDEO_AND_AUDIO|ConfigMode.AUDIO - quality:
ConfigQuality.LOW|ConfigQuality.MED|ConfigQuality.HIGH - orientation:
ConfigOrientation.LANDSCAPE|ConfigOrientation.PORTRAIT - Every field is optional. A field you leave out takes the server's default.
- type :
-
transcription:
- type :
PostTranscriptionConfig - required : false
- enabled:
bool - summary:
SummaryConfig?- enabled:
bool - prompt:
String?
- enabled:
- modelId:
String?
- type :
Returns
Future<void>
Example
const HLSConfig config = HLSConfig(
layout: ConfigLayout(
type: ConfigLayoutGrid.GRID,
priority: ConfigLayoutPriority.SPEAKER,
gridSize: 4,
),
theme: ConfigTheme.LIGHT,
mode: ConfigMode.VIDEO_AND_AUDIO,
);
PostTranscriptionConfig transcription = PostTranscriptionConfig(
enabled: true,
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary",
),
);
await room.startHLS(config: config, transcription: transcription);
stopHLS()
- It is used to stop HLS.
- All participants and localParticipant, will receive the
hlsStateChangedevent withHLS_STOPPINGand thenHLS_STOPPED.
Returns
Future<void>
Example
await room.stopHLS();
startTranscription()
-
It is used to start realtime transcription.
-
All participants and localParticipant, will receive
TRANSCRIPTION_STARTINGevent state andtranscriptionTextevent.
Parameters
1. config
-
type :
TranscriptionConfig -
required :
false -
This specifies the configurations for realtime transcription. You can specify following properties.
TranscriptionConfig.webhookURL: Webhooks will be triggered when the state of realtime transcription is changed. Read more about webhooks hereTranscriptionConfig.summary:SummaryConfig.enabled: Indicates whether realtime transcription summary generation is enabled. Summary will be available after realtime transcription stopped.SummaryConfig.prompt: Optional. Provides guidelines or instructions for generating a custom summary based on the realtime transcription content.
TranscriptionConfig.modelConfig: OptionalMap<String, dynamic>of transcription model settings, sent to the server as they are.
Returns
Future<void>
Example
TranscriptionConfig transcriptionConfig = TranscriptionConfig(
webhookURL: "https://webhook.your-api-server.com",
summary: SummaryConfig(
enabled: true,
prompt:
"Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary",
),
);
await room.startTranscription(config: transcriptionConfig);
stopTranscription()
- It is used to stop realtime transcription.
- All participants and localParticipant, will receive
TRANSCRIPTION_STOPPINGevent state.
Returns
Future<void>
Example
await room.stopTranscription();
startTranslation()
- It is used to start realtime translation.
- The
translationStateChangedevent reports its progress, and thetranslationTextevent delivers the translated text. - Each participant receives text in the language set with
translationLanguageinVideoSDK.createRoom()or withchangeTranslationLanguage(). Learn more in Realtime Translation.
Parameters
- config:
- type :
Map<String, dynamic> - required : false
- Translation settings, sent to the server as they are. Leave it out to use the defaults.
- type :
Returns
Future<void>
Example
await room.startTranslation();
stopTranslation()
- It is used to stop realtime translation.
- The
translationStateChangedevent reportsTRANSLATION_STOPPINGand thenTRANSLATION_STOPPED.
Returns
Future<void>
Example
await room.stopTranslation();
changeTranslationLanguage()
- It is used to change the language in which this participant receives translated text. Other participants keep their own language.
- The
translationLanguageChangedevent fires when the change takes effect.
Parameters
- language:
- type :
String - required : true
- The language code to switch to, for example
"es".
- type :
Returns
Future<void>
Example
await room.changeTranslationLanguage("es");
startWhiteboard()
- It is used to initialize a whiteboard session.
Returns
Future<void>
Example
await room.startWhiteboard();
stopWhiteboard()
- It is used to end a whiteboard session.
Returns
Future<void>
Example
await room.stopWhiteboard();
changeCam()
- It is used to change the camera device.
- Pass a
deviceIdto switch to that camera. You can get the list of cameras usingVideoSDK.getCameras(). A camera the SDK does not know throws aVideoSDKErrorwith code3051. - Call it with no arguments to switch to the next camera, for example from the front camera to the back camera.
- Pass a
customCameraTrackto switch to that camera track. This also turns the camera on. If the switch fails, the SDK stops the track. - A device switch keeps the camera on or off as it was.
VideoSDK.getSelectedVideoDevice()returns the camera you switched to. Before any switch it returns the camera the room opened when you joined.
Parameters
Both parameters are named.
-
deviceId:
- type :
String - required : false
- The
deviceIdof aCameraDeviceInfo.
- type :
-
customCameraTrack:
- type :
CustomStreamTrack - required : false
- A camera track created with
VideoSDK.createCameraVideoTrack().
- type :
Returns
Future<void>
Example
// Switch to a specific camera
final List<CameraDeviceInfo> cameras = await VideoSDK.getCameras() ?? [];
await room.changeCam(deviceId: cameras.last.deviceId);
// Switch to the next camera
await room.changeCam();
// Switch to a camera track you created
final CustomStreamTrack cameraTrack = await VideoSDK.createCameraVideoTrack(
facingMode: FacingMode.BACK,
);
await room.changeCam(customCameraTrack: cameraTrack);
setWebcamQuality()
- It is used to cap the quality of the video your camera sends.
- It applies to the camera video already being sent. While your camera is off, it throws a
VideoSDKErrorwith code3062(ERROR_WEBCAM_NOT_ENABLED), so turn the camera on first. - The cap stays in force when you turn the camera off and on again.
Parameters
- quality:
- type :
VideoQuality - required : true
VideoQuality.LOW,VideoQuality.MEDIUMorVideoQuality.HIGH.
- type :
Returns
Future<void>
Example
await room.setWebcamQuality(VideoQuality.LOW);
uploadBase64File()
-
It is used to upload your file to Videosdk's Temporary storage
-
base64Dataconvert your file to base64 and pass here. -
tokenpass your videosdk token. Read more about token here -
fileNameprovide your fileName with extension -
The method will return the corresponding fileUrl, which will use to retrieve the file from the VideoSDK's storage system.
Parameters
- base64Data: String
- token: String
- fileName: String
Returns
Future<String?>-fileUrl, which you use to retrieve the file from the VideoSDK's storage system.
Example
String? fileUrl = await room.uploadBase64File(
base64Data: "<Your File's base64>", // Convert your file to base64 and pass here
token: "<VIDEOSDK_TOKEN>",
fileName: "myImage.jpeg", // Provide name with extension here,
);
print("fileUrl $fileUrl");
fetchBase64File()
-
It is used to retrieve your file from the Videosdk's Temporary storage
-
urlpass fileUrl which is returned by uploadBase64File() -
tokenpass your videosdk token. Read more about token here -
The method will return image in form of base64 string.
Parameters
- url: String
- token: String
Returns
Future<String?>- the file in form of base64 string.
Example
String? base64 = await room.fetchBase64File(
url: "<Your FileUrl>", // Provide fileUrl which is returned by uploadBase64File()
token: "<VIDEOSDK_TOKEN>",
);
print("base64 $base64");
setAudioDevice()
- It is used to change the audio device.
- You can get the list of audio devices using
VideoSDK.getMics(). - The microphone stays muted or unmuted as it was. Android and iOS have a single audio route, so this changes both the microphone and the speaker.
VideoSDK.getSelectedAudioDevice()returns the device you switched to.
Parameters
- device:
MicrophoneDeviceInfo
Returns
Future<void>
Example
final List<MicrophoneDeviceInfo> devices = await VideoSDK.getMics() ?? [];
await room.setAudioDevice(devices.first);
setAudioDeviceChangeListener()
- It sets a listener that runs whenever the audio route changes, for example when a headset or Bluetooth device connects or disconnects.
- The listener receives the device now in use and every device available.
- Pass
nullto remove the listener.
Parameters
- listener:
- type :
void Function(MicrophoneDeviceInfo? selectedDevice, List<MicrophoneDeviceInfo> devices)? - required : true
- type :
Returns
void
Example
room.setAudioDeviceChangeListener((selectedDevice, devices) {
print("Audio now on ${selectedDevice?.label}, ${devices.length} available");
});
// Stop listening
room.setAudioDeviceChangeListener(null);
changeMic()
- It is used to change the audio input device.
- You can get the list of audio devices using
VideoSDK.getMics(). - Pass a
deviceIdto switch to it. The microphone stays muted or unmuted as it was. A device the SDK does not know throws aVideoSDKErrorwith code3059. - Call it with no arguments to switch to the next microphone.
- Pass a
customMicrophoneTrackto switch to that microphone track. This also unmutes the microphone. If the switch fails, the SDK stops the track. - Called with a
deviceIdbefore you join, it selects that device, and the room uses it when you join. - When you pass a
deviceId,VideoSDK.getSelectedAudioDevice()returns that device. Android and iOS have a single audio route, so the speaker changes too.
Parameters
Both parameters are named.
-
deviceId:
- type :
String - required : false
- The
deviceIdof aMicrophoneDeviceInfo.
- type :
-
customMicrophoneTrack:
- type :
CustomStreamTrack - required : false
- A microphone track created with
VideoSDK.createMicrophoneAudioTrack().
- type :
Returns
Future<void>
Example
// Switch to a specific microphone
final List<MicrophoneDeviceInfo> mics = await VideoSDK.getMics() ?? [];
await room.changeMic(deviceId: mics.first.deviceId);
// Switch to a microphone track you created
final CustomStreamTrack micTrack = await VideoSDK.createMicrophoneAudioTrack();
await room.changeMic(customMicrophoneTrack: micTrack);
pauseAllStreams()
This method pauses active media streams within the room.
Parameters
-
kind: Specifies the type of media stream to be paused. If this parameter is omitted, all media streams (audio, video, and screen share) will be paused.
- Type:
StreamKind? - Optional: Yes
- Possible values:
StreamKind.AUDIO,StreamKind.VIDEOorStreamKind.SHARE(screen-share video).
- Type:
Returns
Future<void>
Example
// Pause every stream
await room.pauseAllStreams();
// Pause only video streams
await room.pauseAllStreams(kind: StreamKind.VIDEO);
resumeAllStreams()
This method resumes media streams that have been paused
Parameters
-
kind: Specifies the type of media stream to be resumed. If this parameter is omitted, all media streams (audio, video, and screen share) will be resumed.
- Type:
StreamKind? - Optional: Yes
- Possible values:
StreamKind.AUDIO,StreamKind.VIDEOorStreamKind.SHARE(screen-share video).
- Type:
Returns
Future<void>
Example
await room.resumeAllStreams();
enableAdaptiveSubscription()
- It is used to turn on adaptive subscription. With it on, the quality of each video you receive follows the size you report with
participant.setViewPort().
Returns
Future<void>
Example
await room.enableAdaptiveSubscription();
disableAdaptiveSubscription()
- It is used to turn off adaptive subscription.
Returns
Future<void>
Example
await room.disableAdaptiveSubscription();
requestMediaRelay()
This method starts relaying selected media streams (like camera video, microphone audio, screen share, etc.) from the current room to a specified destination room.
- A participant in the destination room must accept the request. The answer reaches you with the
mediaRelayRequestResponseevent, andmediaRelayStartedfires when the relay starts.
Parameters
-
destinationRoomId (String) – Required: ID of the room where media should be relayed.
-
token (String) – Optional: Authentication token for the destination room.
-
kinds (
List<StreamKind>) – Optional: The kinds of media to relay. If this parameter is omitted, all of them are relayed.- Possible values:
StreamKind.AUDIO: Relays microphone audio streams.StreamKind.VIDEO: Relays camera video streams.StreamKind.SHARE: Relays screen-sharing video streams.
- Possible values:
Returns
Future<void>
Example
await room.requestMediaRelay(
"<DESTINATION-ROOM-ID>",
token: "<token>",
kinds: [StreamKind.AUDIO, StreamKind.VIDEO],
);
stopMediaRelay()
This method stops the ongoing media relay to a specific destination room.
Parameters
- destinationRoomId (String) – Required: ID of the room where the media relay should be stopped.
Returns
Future<void>
Example
await room.stopMediaRelay("<DESTINATION-ROOM-ID>");
switchTo()
This method moves you from the current room to another, without calling leave() and joining again.
- You receive
roomLeftwithLeaveReason.SWITCH_ROOMfor the room you leave, androomJoinedagain once the switch completes. ThatroomJoinedevent passes aMapwhoseswitchRoomIdis the id of the room you switched to. - The same
Roomobject stays in use, and keeps your handlers.
Parameters
-
roomId (String) – Required: ID of the new room to switch to.
-
token (String) – Optional: Authentication token for the new room.
Returns
Future<void>
Example
await room.switchTo("<ROOM-ID>", token: "<token>");
send()
- It is used to send a message to every other participant over the data channel.
- Pass a
Stringfor a text message or aList<int>for binary data. A message can be at most 15 KiB. - Other participants receive it with the
dataReceivedevent.
Parameters
-
message:
- type :
String|List<int> - required : true
- Any other type throws an
ArgumentError.
- type :
-
reliable:
- type :
bool - required : false
- defaultValue :
true truedelivers messages in order and resends lost ones.falsesends them once, with lower latency.
- type :
Returns
Future<void>- It throws a
VideoSDKErrorwhen the message is not sent:3048when the data channel is not open yet,3072when the message is larger than 15 KiB, and3070when sending fails. A3070failure is also reported on theerrorevent.
Example
try {
await room.send("Hello everyone");
} on VideoSDKError catch (error) {
print("Message not sent: ${error.code} ${error.name}");
}
respondEntry()
- It answers a participant's request to join the room. It does the same as the
allowanddenyfunctions in theentryRequestedevent.
Parameters
-
participantId:
- type :
String - required : true
- The participant who asked to join.
- type :
-
decision:
- type :
String - required : true
"allowed"or"denied".
- type :
Returns
Future<void>
Example
room.on(Events.entryRequested, (Map<String, dynamic> data) async {
await room.respondEntry(data['participantId'], "allowed");
});
getActiveSpeakerId()
- It returns the id of the participant who is speaking, or
nullwhen no one is. - The
speakerChangedevent reports each change.
Returns
String?
Example
String? speakerId = room.getActiveSpeakerId();
getActivePresenterId()
- It returns the id of the participant who is sharing their screen, or
nullwhen no one is. - The
presenterChangedevent reports each change.
Returns
String?
Example
String? presenterId = room.getActivePresenterId();
getAttributes()
- It returns the room's attributes from the server, such as its logs, observability and traces.
Returns
Future<Map<String, dynamic>>
Example
Map<String, dynamic> attributes = await room.getAttributes();
getAppliedVideoConfig()
- It returns the camera settings in use, under the keys
width,height,frameRate,facingMode,codecandapplied. - It returns
nulluntil the camera has been opened once.appliedisfalsewhile the camera is not capturing.
Returns
Future<Map<String, dynamic>?>
Example
Map<String, dynamic>? videoConfig = await room.getAppliedVideoConfig();
print("Camera: ${videoConfig?['width']}x${videoConfig?['height']}");
setVideoEffects()
- It is used to apply video effects to your camera video: framing, low-light correction, style, color filter and background blur. It does the same as
VideoSDK.setVideoEffects(), which also works before you join. To learn more, see the Video Effects guide and the Video Effects Config reference. - Send the whole configuration each time: an effect you leave out goes back to its default. Wait for one call to complete before you make the next.
- While the camera is off, no effect runs. The configuration is kept and applies when the camera starts.
- Background blur works on the default
VideoEffectsPipeline.LEGACYonly. On Android, framing on that pipeline needscom.google.mlkit:face-detection:16.1.7and background blur needscom.google.mlkit:segmentation-selfie:16.0.0-beta6in your app'sbuild.gradle. On iOS, background blur needs iOS 15 or later.
Parameters
- config:
- type :
VideoEffectsConfig - required : true
- type :
Returns
Future<Map<String, dynamic>?>- the effects that are running, under the keysengine,applied,reason,pipeline,framing,lighting,styleandfilter. Whenappliedisfalse,reasonsays why.
Example
final applied = await room.setVideoEffects(
const VideoEffectsConfig(
lighting: VideoEffectsLighting(enabled: true),
background: VideoEffectsBackground(mode: VideoEffectsBackgroundMode.BLUR),
),
);
if (applied?['applied'] != true) {
print("Effects not running: ${applied?['reason']}");
}
getAppliedVideoEffectsConfig()
- It returns the video effects in use, in the same shape that
setVideoEffects()returns.
Returns
Future<Map<String, dynamic>?>
Example
Map<String, dynamic>? effects = await room.getAppliedVideoEffectsConfig();
publishFramingSubject()
- It is used to tell auto-framing where the subject is when you use
VideoEffectsPipeline.GRAPH. Call it each time your own face or person detection finds the subject. The defaultVideoEffectsPipeline.LEGACYfinds the face itself and needs no call. cxandcyare the center of the subject, andwidthandheightits size, all from0to1of the video frame. Pass0aswidthandheightwhen the subject is lost, and the frame zooms back out.
Parameters
- cx: double
- cy: double
- width: double
- height: double
Returns
Future<void>
Example
await room.publishFramingSubject(cx: 0.5, cy: 0.4, width: 0.3, height: 0.4);
setVideoProcessor()
- It runs the camera video you send through a video processor. It works before and after you join.
- On Android, it applies the processor that your app registered under that name with
registerVideoProcessor(). A name that was never registered throws an error. - On iOS, custom processors are not supported. The name is read as the file path or URL of an image, and the camera background is replaced with that image.
- Setting a processor replaces the effects set with
setVideoEffects()on the defaultVideoEffectsPipeline.LEGACY.
Parameters
- processorName:
- type :
String - required : true
- On Android, the name you registered the processor under. On iOS, the file path or URL of the background image.
- type :
Returns
Future<void>
Example
// Android: the name you registered the processor under
await room.setVideoProcessor("VirtualBGProcessor");
// iOS: the file path or URL of the background image
await room.setVideoProcessor("<IMAGE-PATH-OR-URL>");
removeVideoProcessor()
- It removes the video processor set with
setVideoProcessor(), and the effects set withsetVideoEffects()on the defaultVideoEffectsPipeline.LEGACY.
Returns
Future<void>
Example
await room.removeVideoProcessor();
on()
- It is used to listen
Roomrelated events.
Parameters
-
event
- type:
Events - This will specify the event to be listened.
- type:
-
eventHandler
- type:
Function - This will be invoked whenever, specified event occurred.
- The handler can declare fewer parameters than the event delivers. If a parameter type does not match what the event delivers, the handler throws when the event fires, and the error reaches your app uncaught. The other handlers for that event still run.
- type:
Returns
void
Example
room.on(Events.roomJoined, () {
// do something
});
off()
- It is used to remove a handler that you added with
on(). Pass the same event and the same function.
Parameters
Returns
void
Example
void onParticipantJoined(Participant participant) {
// do something
}
room.on(Events.participantJoined, onParticipantJoined);
// Later, for example when your widget is disposed
room.off(Events.participantJoined, onParticipantJoined);
removeAllEventListeners()
- It removes every handler that you added with
on(). - You do not need it after the room: the room removes every handler itself once
roomLeftis delivered.
Returns
void
Example
room.removeAllEventListeners();
Got a Question? Ask us on discord

