Docs / Flutter / LiveKit

LiveKit on Flutter

Beautify a livekit_client camera track. LiveKit's Flutter SDK publishes flutter_webrtc tracks, so Facevity attaches to the track natively.

Demo app: facevity-flutter-demo on GitHub

LiveKit’s Flutter SDK publishes flutter_webrtc tracks, so the plugin’s flutter_webrtc hook does the work: it adds a native processor to the local video track, between the camera capturer and the encoder.

1. Requirements

  • facevity_flutter set up as in the quick start
  • livekit_client 2.x (with flutter_webrtc 0.9.36 or later)
  • iOS: 'flutter_webrtc' in $FacevityRtcHooks in the Podfile. Android detects it automatically.

2. Attach to the camera track

final fv = await Facevity.initialize(licenseAsset: 'assets/facevity/license.fvl', params: BeautyParams.natural);

final room = Room();
await room.connect(serverUrl, accessToken);

final track = await LocalVideoTrack.createCameraTrack(
    const CameraCaptureOptions(cameraPosition: CameraPosition.front));
await fv.rtc.livekit.attachTrack(track.mediaStreamTrack.id!);
await room.localParticipant?.publishVideoTrack(track);

3. After a camera switch

track.restartTrack or switchCamera may create a new MediaStreamTrack. Attach again with its id:

await track.switchCamera('user');
await fv.rtc.livekit.attachTrack(track.mediaStreamTrack.id!);

4. Tear down

await fv.rtc.livekit.detach();
await room.disconnect();

Next: flutter_webrtc · all platforms

Need help with an integration? Contact the Facevity team. We answer integration questions during trials.