MediaSFU Flutter
Essential next steps
- API and reference documentation
- Choose standard, hybrid, or fully headless UI
- Headless and hybrid implementation
- Starter projects and showcases
- Framework examples and recipes
- Current release and migration notes
- Troubleshooting and recovery
Build a MediaSFU room in a Flutter application with mediasfu_sdk. This guide
targets the 2.3.6 API. Obtain that exact package version through your
organisation's approved delivery process and pin it before copying the code.
For an isolated local prototype, use only restricted, revocable development
credentials and never commit them. Before sharing or releasing the app, move
reusable Cloud credentials behind the
production credential boundary.
Install
Add mediasfu_sdk version 2.3.6 through the package source approved for your application, then check the resolved version in pubspec.lock. Use the examples below only with 2.3.6.
dependencies:
mediasfu_sdk: 2.3.6
The package declares Dart >=3.10.0 <4.0.0 and Flutter >=3.38.1.
Before you run a room, complete the camera, microphone, and display-capture permissions required by every platform you ship. On web, use HTTPS for real camera, microphone, and display-capture tests.
Build a room without client credentials
MediasfuGenericOptions accepts createMediaSFURoom and joinMediaSFURoom callbacks. Use them to send only the requested room payload to an authenticated application backend. Your backend applies room policy, holds any long-lived credential, and returns the SDK-compatible room result.
import 'package:mediasfu_sdk/mediasfu_sdk.dart';
import 'package:mediasfu_sdk/components/mediasfu_components/mediasfu_generic.dart'
show MediasfuGenericOptions;
import 'package:mediasfu_sdk/methods/utils/create_join_room.dart'
show CreateJoinRoomResult;
import 'package:mediasfu_sdk/methods/utils/create_room_on_media_sfu.dart'
show CreateMediaSFUOptions;
import 'package:mediasfu_sdk/methods/utils/join_room_on_media_sfu.dart'
show JoinMediaSFUOptions;
abstract interface class RoomBackend {
Future<CreateJoinRoomResult> create(CreateMediaSFURoomOptions payload);
Future<CreateJoinRoomResult> join(JoinMediaSFURoomOptions payload);
}
class RoomGateway {
RoomGateway(this.backend);
final RoomBackend backend;
Future<CreateJoinRoomResult> create(CreateMediaSFUOptions request) {
return backend.create(request.payload);
}
Future<CreateJoinRoomResult> join(JoinMediaSFUOptions request) {
return backend.join(request.payload);
}
}
MediasfuGeneric room(RoomBackend backend) {
final gateway = RoomGateway(backend);
return MediasfuGeneric(
options: MediasfuGenericOptions(
createMediaSFURoom: gateway.create,
joinMediaSFURoom: gateway.join,
),
);
}
The SDK calls these callbacks with CreateMediaSFUOptions or JoinMediaSFUOptions; the room intent is in request.payload. The gateway above deliberately ignores the request's credential fields. Do not forward those fields to your backend or use the built-in createRoomOnMediaSFU and joinRoomOnMediaSFU helpers for a production client.
Your backend adapter should return CreateJoinRoomResult with the room data expected by the SDK. A successful create or join lets the supplied room continue into its room flow. For an expired app session, denied room policy, or unavailable room, show the application error, let the person sign in or choose another room as appropriate, and retry only with a fresh backend response. See the secure backend pattern for the server boundary.