Flutter Quickstart

Get started with LiveKit and Flutter

1. Install LiveKit SDK

Include this package to your pubspec.yaml

---
dependencies:
livekit_client: <version>

2. Declare permissions

Camera and microphone usage need to be declared in your Info.plist file.

<dict>
...
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses your camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) uses your microphone</string>
...
</dict>

Your application can still run a voice call when it is switched to the background if the background mode is enabled. Select the app target in Xcode, click the Capabilities tab, enable Background Modes, and check Audio, AirPlay, and Picture in Picture.

Your Info.plist should have the following entries:

<dict>
...
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>

(We strongly recommend using Flutter 3.3.0+. if you are using Flutter 3.0.0 or below, please see this note in our SDK README.)

2. Connect to a room, publish video & audio

final roomOptions = RoomOptions(
adaptiveStream: true,
dynacast: true,
// ... your room options
)
final room = Room();
await room.connect(url, token, roomOptions: roomOptions);
try {
// video will fail when running in ios simulator
await room.localParticipant.setCameraEnabled(true);
} catch (error) {
print('Could not publish video, error: $error');
}
await room.localParticipant.setMicrophoneEnabled(true);

3. Next Steps

Happy coding!