UTD Stream ڈویلپرز پر واپس

< Flutter UI کٹ />

UTD Audio Room Kit

سیٹس، ریئل-ٹائم چیٹ اور ماڈریشن کے ساتھ ڈراپ-اِن لائیو آڈیو رومز۔

ورژن 4.2.1pub.dev پر
iOS 11+Android 21+
audio_room_kit.dart
import 'package:utd_audio_room_kit/utd_audio_room_kit.dart';

// tokenProvider returns the token your backend minted for THIS user (POST /api/v1/token
// with X-App-Secret). See /developers/stream/guide/quick-start for the backend endpoint.
UTDAudioRoom(
  appId: '<utd-app-id>',
  appKey: '<utd-app-key>', // identifies the project; cannot mint a user token by itself
  userId: 'user123',
  userName: 'John Doe',
  roomId: 'room456',
  roomOwnerId: 'owner789',
  tokenProvider: () async => UTDTokenResponse.fromJson(
    await myBackend.getRoomToken('room456', type: 'audio_room'),
  ),
);

Drop-in

مکمل UI

0

بیک اینڈ سرورز

EN · AR

بلٹ-اِن i18n

PiP

+ چھوٹا کریں

< utd_audio_room_kit />

اہم خصوصیات

UTD Stream Engine سے چلنے والے لائیو آڈیو روم تجربے کے لیے ایک مکمل، حسبِ ضرورت Flutter پیکیج۔ تیار روم UI میں سیٹ مینجمنٹ، بولنے کی درخواستیں، ممبر لسٹ، ریئل ٹائم چیٹ، میڈیا کنٹرول، مینیمائز/PiP اور ہوسٹ/ایڈمن کی مکمل ماڈریشن شامل ہے۔ ٹوکن آپ کا اپنا بیک اینڈ جاری کرتا ہے اور tokenProvider کے ذریعے دیے جاتے ہیں۔

ڈراپ-اِن آڈیو روم UI — کوئی اضافی کوڈ نہیں

سیٹ مینجمنٹ: لینا، چھوڑنا، تبدیل کرنا، lock، unlock، kick، mute، swap

approve/reject کے ساتھ بولنے-کی-درخواست قطار

ہوسٹ/ایڈمن ایکشنز کے ساتھ ممبر فہرست (mute، kick، invite، ban، promote/demote)

بیچنگ اور ڈی-ڈَپ کے ساتھ ریئل-ٹائم ڈیٹا-چینل چیٹ

بلوٹوتھ کو ترجیح دینے والی روٹنگ کے ساتھ مائیک اور اسپیکر کنٹرولز

درجہ بند ری کنکشن (لائٹ سِنک <15s، فل سِنک <60s)

فلوٹنگ اوورلے اور Android OS Picture-in-Picture میں minimize

تھیم کسٹمائزیشن اور بلٹ-اِن i18n (EN/AR)

مکمل سیکشن کی تبدیلی (ہیڈر، پیغامات، کنٹرولز، بیک گراؤنڈ، سیٹس)

سرور سے سائن شدہ ٹوکن: آپ کا بیک اینڈ بناتا ہے، کٹ tokenProvider لیتی ہے

< utd_audio_room_kit />

شروع کریں

1

انسٹال کریں

Terminal
flutter pub add utd_audio_room_kit
2

pub.dev پر دیکھیں

سیٹس، ریئل-ٹائم چیٹ اور ماڈریشن کے ساتھ ڈراپ-اِن لائیو آڈیو رومز۔

< utd_audio_room_kit />

API حوالہ

Main widget

The drop-in prebuilt audio-room widget that hosts the full UI and connection lifecycle.

UTDAudioRoomwidget
const UTDAudioRoom({required String appId, required String appKey, required String userId, required String userName, required String roomId, required String roomOwnerId, Set<String> adminIds, UTDAudioRoomConfig config, List<UTDRoomMode> modes, UTDRoomController? controller, ...})

Prebuilt audio-room widget. Takes its token from tokenProvider (your backend mints it with the Server Secret), connects to the media room, and renders seats, chat and controls. Without tokenProvider it falls back to minting with the appKey, which works only on projects that still allow app-key minting.

پیرامیٹرز

  • appIdStringلازمی

    UTD Stream Engine app ID.

  • appKeyStringلازمی

    Publishable app key; identifies the project. On a project with default settings it cannot mint a token that names a user (403 appkey_identity_mint_disabled): mint on your backend and pass tokenProvider. The server secret never ships.

  • userIdStringلازمی

    Local user identity.

  • userNameStringلازمی

    Local user display name.

  • roomIdStringلازمی

    Room name to join.

  • roomOwnerIdStringلازمی

    Identity of the room owner; the owner joins as host.

  • adminIdsSet<String>ڈیفالٹ = const {}

    Identities the app treats as admins at join.

  • adminIdsResolverFuture<Set<String>> Function()?ڈیفالٹ = null

    Async admin-list source; triggers a non-blocking self-upgrade if it lists the local user.

  • adminIdsNowSet<String> Function()?ڈیفالٹ = null

    Sync admin-list probe used at token time without waiting.

  • layoutModeStringڈیفالٹ = '3'

    Room mode id selecting the seat layout / seat count.

  • configUTDAudioRoomConfigڈیفالٹ = const UTDAudioRoomConfig()

    Behavior, theming and custom-widget configuration.

  • modesList<UTDRoomMode>ڈیفالٹ = const []

    Custom room modes registered on the controller.

  • controllerUTDRoomController?ڈیفالٹ = null

    Optional externally-owned controller (e.g. when restoring from minimize).

  • onControllerReadyvoid Function(UTDRoomController)?ڈیفالٹ = null

    Called once the controller is created/attached.

  • onConnectionChangedvoid Function(bool isConnected)?ڈیفالٹ = null

    Fired on connect success/failure.

  • onSeatTapvoid Function(int index, SeatState seat)?ڈیفالٹ = null

    Called when a seat is tapped.

  • onSeatChangedvoid Function(List<SeatState> seats)?ڈیفالٹ = null

    Called whenever seat state changes.

  • onConnectErrorvoid Function(Object error, StackTrace)?ڈیفالٹ = null

    Called when the initial connect fails.

Room controller

Top-level controller owning connection, sub-controllers, roles, bans and speaker flows.

UTDRoomControllerconstructor
UTDRoomController()

Creates the controller and its seat, media, chat, minimize and PiP sub-controllers. Usually created internally by UTDAudioRoom.

initApimethod
void initApi({String baseUrl, String tokenBaseUrl, String? appId, required String appKey})

Initializes the engine and token API clients. Must be called before connect/generateToken. Token issuance and in-room ops use different hosts.

پیرامیٹرز

  • baseUrlStringڈیفالٹ = UTDApiClient.defaultBaseUrl

    In-room engine host for seat/speaker/ban/role calls.

  • tokenBaseUrlStringڈیفالٹ = UTDApiClient.defaultTokenBaseUrl

    Edge host used for token generation.

  • appIdString?ڈیفالٹ = null

    Engine app ID.

  • appKeyStringلازمی

    Publishable app key sent as X-App-Key. Mint user tokens on your backend instead (see tokenProvider).

connectmethodasync
Future<void> connect({required String url, required String token, int seatCount = 9, bool enableMicOnJoin = false, bool useSpeaker = true, Map<String,String> userAttributes, String? roomName})

Connects to the media room with the given url/token, initializes seats, wires data/role/ban/chat-lock handlers, and optionally enables the mic and speaker.

پیرامیٹرز

  • urlStringلازمی

    Media engine server URL.

  • tokenStringلازمی

    Media engine access token.

  • seatCountintڈیفالٹ = 9

    Number of seats to initialize.

  • enableMicOnJoinboolڈیفالٹ = false

    Publish the local mic on connect.

  • useSpeakerboolڈیفالٹ = true

    Prefer Bluetooth/loudspeaker output on join.

  • userAttributesMap<String,String>ڈیفالٹ = const {}

    Cosmetic participant attributes (avatar/frame/etc.).

  • roomNameString?ڈیفالٹ = null

    Room name used for seat API calls.

واپسی: Future<void>

generateTokenmethodasync
Future<UTDTokenResponse> generateToken({required String identity, required String roomName, required String roomOwnerId, String role = 'audience', String? name, int? seatCount, String? seatMode, int? hostSeat, String? modeId, ...})

Requests a media token from the engine and applies the returned per-user bearer to the in-room clients. Throws UTDBannedException on a 403 banned response.

پیرامیٹرز

  • identityStringلازمی

    User identity.

  • roomNameStringلازمی

    Room name.

  • roomOwnerIdStringلازمی

    Room owner identity.

  • typeStringڈیفالٹ = 'audio_room'

    Room type.

  • roleStringڈیفالٹ = 'audience'

    Requested role (host/admin/audience).

  • nameString?ڈیفالٹ = null

    Display name.

  • seatCountint?ڈیفالٹ = null

    Initial seat count (host only).

  • modeIdString?ڈیفالٹ = null

    Room mode id (host only).

واپسی: Future<UTDTokenResponse>

leavemethodasync
Future<void> leave()

Leaves the room: tears down listeners, drains any pending mic publish, disconnects the media room, and resets minimize/PiP state.

واپسی: Future<void>

changeRolemethodasync
Future<UTDRoleChangeResult> changeRole({required String targetIdentity, required String role})

Changes a participant's role (owner-only; server returns 403 otherwise). Optimistically caches the result; throws on REST error.

پیرامیٹرز

  • targetIdentityStringلازمی

    Identity whose role changes.

  • roleStringلازمی

    New role (host/admin/guest/audience).

واپسی: Future<UTDRoleChangeResult>

banUsermethodasync
Future<bool> banUser(String identity, {String? reason, int? durationSeconds, bool global = false})

Bans a user. Room-scoped by default; pass global true for a project-wide ban and durationSeconds null for permanent. Returns true on success.

پیرامیٹرز

  • identityStringلازمی

    User to ban.

  • reasonString?ڈیفالٹ = null

    Optional ban reason.

  • durationSecondsint?ڈیفالٹ = null

    Ban duration; null = permanent.

  • globalboolڈیفالٹ = false

    True for a project-wide ban.

واپسی: Future<bool>

lockCommentsmethodasync
Future<bool> lockComments()

Locks room chat so only host/admin may send (host/admin-only). State is confirmed by the server broadcast, not set optimistically.

واپسی: Future<bool>

requestToSpeakmethodasync
Future<Map<String,dynamic>?> requestToSpeak()

Audience requests to speak (request mode). Returns the API result map, or null on error / when not ready.

واپسی: Future<Map<String,dynamic>?>

inviteToSpeakmethodasync
Future<Map<String,dynamic>?> inviteToSpeak(String targetIdentity, {int? seatIndex})

Host/admin invites a user to speak, optionally targeting a specific seat. Returns the API result map or null.

پیرامیٹرز

  • targetIdentityStringلازمی

    Identity to invite.

  • seatIndexint?ڈیفالٹ = null

    Target seat the invitee is seated on if accepted.

واپسی: Future<Map<String,dynamic>?>

isConnectedgetter
bool get isConnected

True when the room connection state is connected.

واپسی: bool

isHostOrAdmingetter
bool get isHostOrAdmin

Whether the local participant's role is host or admin.

واپسی: bool

participantsStreamgetterasync
Stream<List<UTDParticipant>> get participantsStream

Stream of all room participants, emitting on join/leave/attribute/metadata changes.

واپسی: Stream<List<UTDParticipant>>

roleChangeStreamgetterasync
Stream<UTDRoleChangeEvent> get roleChangeStream

Stream of role changes for all participants (promotions, demotions, engine auto-corrections).

واپسی: Stream<UTDRoleChangeEvent>

activeSpeakersproperty
final ValueNotifier<Set<String>> activeSpeakers

Reactive set of identities currently speaking, polled from the media engine every 300ms.

واپسی: ValueNotifier<Set<String>>

commentsLockedproperty
final ValueNotifier<bool> commentsLocked

Reactive whether room chat is currently locked (server-driven; never set optimistically).

واپسی: ValueNotifier<bool>

onBannedcallback
void Function(UTDBanNotice notice)? onBanned

Fired once when the local user is banned from any source (data message, removal, or token 403). Wired internally by UTDAudioRoom.

واپسی: void Function(UTDBanNotice)?

disposemethod
void dispose()

Releases all resources: timers, subscriptions, notifiers, sub-controllers and API clients.

Seat & stage control

Seat state management; all mutations go through the REST API and apply from server _seat_update messages.

UTDSeatControllerclass
UTDSeatController(UTDRoomManager roomManager)

Manages reactive seat state. Mutations call the REST API; local state updates only from _seat_update data messages or room _seats metadata.

takeSeatmethodasync
Future<bool> takeSeat(int index, String userId)

Requests microphone (and Bluetooth on Android) permissions then takes the seat at index via the API. State arrives via _seat_update.

پیرامیٹرز

  • indexintلازمی

    Target seat index.

  • userIdStringلازمی

    Identity taking the seat.

واپسی: Future<bool>

leaveSeatmethodasync
Future<bool> leaveSeat(String userId)

Leaves the user's current seat via the API.

پیرامیٹرز

  • userIdStringلازمی

    Identity leaving the seat.

واپسی: Future<bool>

moveSeatmethodasync
Future<bool> moveSeat(String userId, int targetSeat)

Atomically moves the user to another seat via the API.

پیرامیٹرز

  • userIdStringلازمی

    Identity to move.

  • targetSeatintلازمی

    Destination seat index.

واپسی: Future<bool>

lockSeatmethodasync
Future<bool> lockSeat(int index, {required String identity})

Admin locks the seat at index (host/admin). State arrives via _seat_update.

پیرامیٹرز

  • indexintلازمی

    Seat to lock.

  • identityStringلازمی

    Acting host/admin identity.

واپسی: Future<bool>

kickFromSeatmethodasync
Future<bool> kickFromSeat(int index, {required String identity})

Removes the occupant from the seat at index (host/admin only).

پیرامیٹرز

  • indexintلازمی

    Seat to vacate.

  • identityStringلازمی

    Acting host/admin identity.

واپسی: Future<bool>

setupSeatsmethodasync
Future<bool> setupSeats({required String identity, required int seatCount, required String seatMode, String? modeId})

Changes seat configuration mid-room (count/mode/modeId) (host/admin only).

پیرامیٹرز

  • identityStringلازمی

    Acting host/admin identity.

  • seatCountintلازمی

    New seat count.

  • seatModeStringلازمی

    New seat mode ('free'/'request').

  • modeIdString?ڈیفالٹ = null

    New room mode id.

واپسی: Future<bool>

seatsproperty
final ValueNotifier<List<SeatState>> seats

Reactive list of all seat states.

واپسی: ValueNotifier<List<SeatState>>

pendingRequestsproperty
final ValueNotifier<List<SpeakerRequest>> pendingRequests

Reactive list of pending speaker requests (for host/admin UI).

واپسی: ValueNotifier<List<SpeakerRequest>>

getSeatIndexByUserIdmethod
int getSeatIndexByUserId(String userId)

Returns the seat index occupied by a user, or -1 if not seated.

پیرامیٹرز

  • userIdStringلازمی

    Identity to look up.

واپسی: int

isSeatAvailablemethod
bool isSeatAvailable(int index, {String? userId})

Whether the seat at index is empty, unlocked and not reserved for someone else.

پیرامیٹرز

  • indexintلازمی

    Seat index to test.

  • userIdString?ڈیفالٹ = null

    User to evaluate reservations against.

واپسی: bool

Media control

Mic, camera, speaker and Bluetooth-routing controls, kept in sync with server/host-side mutes.

UTDMediaControllerclass
UTDMediaController(UTDRoomManager roomManager)

Controls mic, camera and speaker state and listens to the engine's mute/permission events to keep reactive state authoritative.

setMicrophoneEnabledmethodasync
Future<void> setMicrophoneEnabled(bool enabled)

Enables/disables the local mic. Refuses to publish on a non-connected room to avoid the addTransceiver-on-disposed-track crash.

پیرامیٹرز

  • enabledboolلازمی

    Target mic state.

واپسی: Future<void>

toggleMicrophonemethodasync
Future<void> toggleMicrophone()

Toggles the local microphone on/off.

واپسی: Future<void>

applyBluetoothAudioRoutingmethodasync
Future<void> applyBluetoothAudioRouting()

Re-applies the Android communication audio config with forceHandleAudioRouting so Bluetooth routing works after connect/publish; iOS uses the AVAudioSession path.

واپسی: Future<void>

setSpeakerOnmethodasync
Future<void> setSpeakerOn(bool on)

Routes audio to the loudspeaker (true) or earpiece (false).

پیرامیٹرز

  • onboolلازمی

    Speakerphone on/off.

واپسی: Future<void>

muteAllRemoteAudiomethod
void muteAllRemoteAudio(bool mute)

Mutes/unmutes playback of all remote participants' audio (and enforces it on late-subscribed tracks).

پیرامیٹرز

  • muteboolلازمی

    Whether to mute remote audio.

isMicEnabledproperty
final ValueNotifier<bool> isMicEnabled

Reactive local mic state, kept in sync with track mute/unmute events.

واپسی: ValueNotifier<bool>

canPublishproperty
final ValueNotifier<bool> canPublish

Reactive whether the local participant may publish mic/camera; flips false on demotion.

واپسی: ValueNotifier<bool>

Chat

Room chat send/receive with comment-lock gating and a bounded message buffer.

UTDChatControllerclass
UTDChatController(UTDRoomManager roomManager)

Sends and receives room chat over the data channel, enforcing the comment-lock gate and capping retained messages at 300.

sendMessagemethodasync
Future<void> sendMessage(String text, {Map<String,dynamic>? userData})

Sends a chat message (trimmed, non-empty). Refused when comments are locked and the local user is not host/admin.

پیرامیٹرز

  • textStringلازمی

    Message body.

  • userDataMap<String,dynamic>?ڈیفالٹ = null

    Optional extra payload attached to the message.

واپسی: Future<void>

addDisplayMessagemethod
void addDisplayMessage(UTDChatMessage message)

Appends a message to the local list without sending it (used for system lines).

پیرامیٹرز

  • messageUTDChatMessageلازمی

    Message to display locally.

clearMessagesmethod
void clearMessages()

Clears the local message list.

messagesproperty
final ValueNotifier<List<UTDChatMessage>> messages

Reactive list of chat messages (bounded to the most recent 300).

واپسی: ValueNotifier<List<UTDChatMessage>>

Configuration & theming

Behavior config, color tokens, localized strings and minimize/PiP options.

UTDAudioRoomConfigconstructor
const UTDAudioRoomConfig({bool showControlsBar = true, bool turnOnMicrophoneWhenJoining = false, bool useSpeakerWhenJoining = true, int hostSeatIndex = 0, UTDRoomTheme theme, UTDRoomStrings? strings, bool enableMinimize = true, Widget? headerWidget, ...})

Configures room behavior, theme, strings and custom section/seat builders. Replaces the prebuilt config.

پیرامیٹرز

  • showControlsBarboolڈیفالٹ = true

    Show the default controls bar.

  • showSeatNamesboolڈیفالٹ = true

    Show occupant names under seats.

  • enableMinimizeboolڈیفالٹ = true

    Allow minimizing the room to a floating overlay.

  • turnOnMicrophoneWhenJoiningboolڈیفالٹ = false

    Publish the mic on join.

  • useSpeakerWhenJoiningboolڈیفالٹ = true

    Prefer speaker/Bluetooth output on join.

  • hostSeatIndexintڈیفالٹ = 0

    Seat index reserved for the host.

  • themeUTDRoomThemeڈیفالٹ = const UTDRoomTheme()

    Color tokens for the default UI.

  • stringsUTDRoomStrings?ڈیفالٹ = null

    Localized strings; null = English defaults.

  • autoHostMicboolڈیفالٹ = true

    Auto-enable the host's mic even if join-mic is false.

  • autoSeatHostboolڈیفالٹ = true

    Auto-seat the host on hostSeatIndex if empty.

  • headerWidgetWidget?ڈیفالٹ = null

    Custom header replacing the default.

  • seatBuilderWidget Function(SeatState, double)?ڈیفالٹ = null

    Custom builder for a seat slot.

  • avatarBuilderWidget Function(String,double,Map<String,String>,bool,int,String)?ڈیفالٹ = null

    Custom occupant avatar builder.

  • userInRoomAttributesMap<String,String>ڈیفالٹ = const {}

    Cosmetic attributes published to other participants.

UTDAudioRoomConfig.hostconstructor
factory UTDAudioRoomConfig.host()

Factory preset for a host (microphone on when joining).

resolveStringsmethod
UTDRoomStrings resolveStrings()

Returns the configured strings or the English defaults.

واپسی: UTDRoomStrings

UTDRoomThemeconstructor
const UTDRoomTheme({Color background, Color surface, Color onSurface, Color primary, Color danger, Color seatRingSpeaking, Color badgeHost, Color badgeAdmin, Color badgeGuest, Color sheetBackground, Color bubbleBackground, ...})

Color tokens for the built-in default UI. Every field has a dark-room default, so const UTDRoomTheme() is a complete theme.

پیرامیٹرز

  • backgroundColorڈیفالٹ = Color(0xFF14121C)

    Full-screen room background.

  • primaryColorڈیفالٹ = Color(0xFF6C5CE7)

    Accent / call-to-action color.

  • dangerColorڈیفالٹ = Color(0xFFE74C3C)

    Destructive color (leave/kick/ban).

  • seatRingSpeakingColorڈیفالٹ = Color(0xFF2ECC71)

    Ring around an actively-speaking seat.

  • badgeHostColorڈیفالٹ = Color(0xFFFFA726)

    Host role badge color.

  • badgeAdminColorڈیفالٹ = Color(0xFF448AFF)

    Admin role badge color.

copyWithmethod
UTDRoomTheme copyWith({Color? background, Color? primary, Color? danger, ...})

Returns a copy of the theme overriding only the supplied color tokens.

واپسی: UTDRoomTheme

UTDRoomStrings.enconstructor
factory UTDRoomStrings.en()

English defaults for all built-in UI labels (seat actions, requests, host panels, comment-lock, templated lines).

UTDRoomStrings.arconstructor
factory UTDRoomStrings.ar()

Arabic defaults for all built-in UI labels.

UTDMinimizeConfigconstructor
const UTDMinimizeConfig({VoidCallback? onClose, MiniOverlayBuilder? overlayBuilder, double overlayWidth = 120, double overlayHeight = 120, bool enableOSPip = false, int pipAspectWidth = 1, int pipAspectHeight = 1, ...})

Configures the minimize floating overlay and optional Android OS-level Picture-in-Picture (enableOSPip).

پیرامیٹرز

  • onCloseVoidCallback?ڈیفالٹ = null

    Called when the room is closed from the overlay.

  • overlayBuilderMiniOverlayBuilder?ڈیفالٹ = null

    Custom floating-overlay builder.

  • enableOSPipboolڈیفالٹ = false

    Enable Android 12+ system PiP in addition to the overlay.

  • pipAspectWidthintڈیفالٹ = 1

    PiP aspect ratio numerator.

  • pipAspectHeightintڈیفالٹ = 1

    PiP aspect ratio denominator.

Models & enums

Data models for seats, room modes, chat and connection state.

SeatStateclass
const SeatState({required int index, String? occupantUserId, bool isLocked = false, bool isMuted = false, String? reservedFor, Map<String,String> attributes})

Immutable (Equatable) state of a single seat: index, occupant, lock/mute flags, reservation and occupant attributes.

پیرامیٹرز

  • indexintلازمی

    Seat index (0 = host seat).

  • occupantUserIdString?ڈیفالٹ = null

    Occupant identity; null = empty.

  • isLockedboolڈیفالٹ = false

    Whether the seat is admin-locked.

  • isMutedboolڈیفالٹ = false

    Whether the occupant's mic is muted.

  • reservedForString?ڈیفالٹ = null

    Identity this seat is reserved for.

  • attributesMap<String,String>ڈیفالٹ = const {}

    Occupant cosmetic attributes (avatar, frame, etc.).

SpeakerRequestclass
const SpeakerRequest({required int id, required String identity, String? createdAt})

A pending request to speak: id, requester identity and createdAt timestamp.

پیرامیٹرز

  • idintلازمی

    Request id.

  • identityStringلازمی

    Requesting identity.

  • createdAtString?ڈیفالٹ = null

    Creation timestamp.

RoomSeatStateclass
const RoomSeatState({required int count, required String mode, String? modeId, required List<SeatState> seats, required List<SpeakerRequest> requests})

Full seat snapshot from the backend _seats namespace: count, mode, modeId, seats and pending requests.

پیرامیٹرز

  • countintلازمی

    Seat count.

  • modeStringلازمی

    Seat mode ('free'/'request').

  • modeIdString?ڈیفالٹ = null

    Room mode id.

  • seatsList<SeatState>لازمی

    Per-seat states.

  • requestsList<SpeakerRequest>لازمی

    Pending speaker requests.

UTDRoomModeclass
const UTDRoomMode({required String id, required int seatCount, required List<List<int>> rows, double? seatSize, UTDSeatContainerBuilder? containerBuilder, UTDBackgroundBuilder? backgroundBuilder, String? displayName})

Defines a seat layout mode: id, seat count, row arrangement and optional custom container/background builders. Identity is its id.

پیرامیٹرز

  • idStringلازمی

    Unique mode id (e.g. '3').

  • seatCountintلازمی

    Number of seats.

  • rowsList<List<int>>لازمی

    Seat-index layout per row.

  • seatSizedouble?ڈیفالٹ = null

    Explicit seat size override.

  • containerBuilderUTDSeatContainerBuilder?ڈیفالٹ = null

    Custom seat-grid container builder.

  • backgroundBuilderUTDBackgroundBuilder?ڈیفالٹ = null

    Mode-specific background builder.

computeSeatSizemethod
double computeSeatSize(double screenWidth)

Single source of truth for the seat slot size in logical px, scaled sub-linearly (sqrt) with screen width and clamped to 52–120.

پیرامیٹرز

  • screenWidthdoubleلازمی

    Available screen width.

واپسی: double

UTDRoomMode.defaultModefield
static const UTDRoomMode defaultMode

Built-in default mode: id '3', 9 seats in a 1-4-4 layout.

واپسی: UTDRoomMode

UTDChatMessageclass
UTDChatMessage({required String senderUserId, required String senderName, required String text, required DateTime timestamp, Map<String,dynamic> userData, String? messageID})

A chat message with sender, text, timestamp, arbitrary userData and an auto-generated messageID. JSON-serializable.

پیرامیٹرز

  • senderUserIdStringلازمی

    Sender identity.

  • senderNameStringلازمی

    Sender display name.

  • textStringلازمی

    Message body.

  • timestampDateTimeلازمی

    Message time.

  • userDataMap<String,dynamic>ڈیفالٹ = const {}

    Extra payload (e.g. system-line markers).

  • messageIDString?ڈیفالٹ = null

    Message id; auto-generated when omitted.

UTDConnectionStateenum
enum UTDConnectionState { disconnected, connecting, connected, reconnecting, error }

Room connection state: disconnected, connecting, connected, reconnecting, error.

واپسی: UTDConnectionState

Tokens, errors and recovery

Added after the first published reference: server-signed tokens, the error catalog, redial hooks and chat bans. Source: the published package.

tokenProvider (widget)property
final Future<UTDTokenResponse?> Function()? tokenProvider

Supplies the token instead of the kit minting one. Server-signed pattern (production): your backend calls POST /api/v1/token with X-App-Secret and a verified identity, and the provider returns that response as a UTDTokenResponse; the widget adopts it, so the per-user bearer is applied to every in-room call. The kit calls it on the first join and on every automatic redial, so it must return a fresh token each time. If it throws or returns null the widget falls back to minting with the appKey, which hardened projects refuse with 403 appkey_identity_mint_disabled.

UTDTokenResponseclass
class UTDTokenResponse { final String token; final String url; final String roomName; final String userToken; final int? userTokenExpiresIn; final Map<String, dynamic>? seats; factory UTDTokenResponse.fromJson(Map<String, dynamic> json) }

The answer of POST /api/v1/token. fromJson reads the engine's snake_case body (token, url, room_name, user_token, user_token_expires_in, seats) and also accepts camelCase. userToken is the per-user bearer for in-room moderation calls; the kit renews it at 80% of userTokenExpiresIn.

tokenProvider (controller)property
Future<UTDTokenResponse> Function()? tokenProvider

Token source used by recovery and by rejoin(). Set it when you create the controller yourself and your backend signs tokens; without it (and without an earlier generateToken call) the kit cannot redial and calls onRejoinFailed.

autoRejoinEnabledproperty
bool autoRejoinEnabled = true

Whether the kit redials by itself after a drop. Turn off only if your app owns recovery; rejoin() stays available.

autoRejoinMaxAttemptsproperty
int autoRejoinMaxAttempts = 10

How many redials the kit makes before giving up and calling onRejoinFailed. Waits grow 1, 2, 4, 8, 16 s then stay at 30 s, each with plus or minus 20% jitter; see the Reconnection guide.

onRejoinFailedcallback
void Function()? onRejoinFailed

Called when the kit has stopped trying to get the user back: the attempts failed, or there was no token source. Show an error and leave the room. Not called when your app left, the user was banned or signed in elsewhere, or the controller was disposed.

onForceExitcallback
void Function()? onForceExit

Called when the media session stayed disconnected for more than 60 seconds, so the app can tear down a dead room screen. Independent of the redial timer.

rejoinmethodasync
Future<bool> rejoin({int? maxAttempts})

Starts the redial loop now (the same one the kit runs automatically). Returns false when the kit has no way to mint a token or the attempts failed. Two calls never run at once.

پیرامیٹرز

  • maxAttemptsint?

    Attempts to make; defaults to autoRejoinMaxAttempts.

واپسی: Future<bool> — True when the user is back in the room.

chatBannedproperty
final ValueNotifier<bool> chatBanned

True while the local user is on the room's chat-ban list (written by your backend with PUT /rooms/:room/chat-bans). Bind your composer to it to disable the input the moment the ban lands.

UTDChatBanListclass
class UTDChatBanList

The room's chat-ban list as the kit reads it from room metadata. Exported if you want to read it yourself.

utdErrorCodeOfmethod
String utdErrorCodeOf(Object error)

The stable code for an error: the engine's code when it is an engine refusal that carries one; network_error when the token call got no HTTP response at all; otherwise unknown.

پیرامیٹرز

  • errorObjectلازمی

    The exception caught around a token or join call.

واپسی: String — A code from UTDErrorCode, or 'unknown'.

utdErrorInfomethod
UTDErrorInfo utdErrorInfo(String? code)

The catalog entry for a code (case-insensitive), or the unknown entry when it is null or not recognised. See the Errors guide for every code.

پیرامیٹرز

  • codeString?لازمی

    An engine code such as 'user_banned'.

واپسی: UTDErrorInfo — The entry; never null.

UTDErrorInfoclass
class UTDErrorInfo { final String code; final UTDErrorAction action; bool get retryable; String message(String lang); String hint(String lang) }

One catalog entry. message(lang) is safe to show an end user (never mentions billing or credentials); hint(lang) is for your logs. lang is en or ar; any other language, and Hindi until reviewed, gives English. retryable is true for retryWithBackoff and refreshToken.

UTDErrorActionenum
enum UTDErrorAction { fixIntegration, retryWithBackoff, doNotRetry, refreshToken, contactSupport }

What to do about an error: fix your integration; retry with backoff; do not retry; mint a new token and retry once; or contact UTD support.

lastSeatErrorproperty
final ValueNotifier<UTDSeatError?> lastSeatError

Why the last takeSeat or moveSeat failed before it reached the engine. Null after a success. An engine refusal (seat taken, locked, banned) returns false with no code.

UTDSeatErrorclass
class UTDSeatError { final String code; final String message; final String messageAr; final bool retryable }

A seat-mutation failure reason. code is one of UTDSeatErrorCode: 'connecting' (the session is still connecting or reconnecting; retry shortly, retryable true) or 'not_connected' (disconnected for good; rejoin first, retryable false).

UTD کے ساتھ تعمیر کے لیے تیار ہیں؟

اپنا اکاؤنٹ بنائیں، اپنے ماسٹر والٹ کو فنڈ کریں، اور جن سروسز کی ضرورت ہے انہیں آن کریں۔