< کیت رابط کاربری Flutter />
UTD Audio Room Kit
اتاقهای صوتی زندهٔ آمادهٔ استفاده با صندلیها، چت بیدرنگ و مدیریت محتوا.
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 />
ویژگیهای کلیدی
یک بستهٔ Flutter کامل و قابلشخصیسازی برای تجربهٔ اتاق صوتی زنده بر پایهٔ UTD Stream Engine. رابط آمادهٔ اتاق شامل مدیریت صندلیها، درخواست صحبت، فهرست اعضا، گفتگوی لحظهای، کنترل رسانه، کوچکسازی/PiP و مدیریت کامل میزبان/ادمین است؛ توکنها را بکاند خودتان صادر میکند و از طریق tokenProvider ارسال میشوند.
رابط کاربری آمادهٔ اتاق صوتی — بدون کد اضافی
مدیریت صندلی: گرفتن، ترک، جابهجایی، lock، unlock، kick، mute، swap
صف درخواست صحبت با approve/reject
فهرست اعضا با اقدامات میزبان/ادمین (mute، kick، invite، ban، promote/demote)
چت بیدرنگ از طریق data-channel با دستهبندی و حذف تکرار
کنترل میکروفون و بلندگو با مسیریابی با اولویت بلوتوث
اتصال مجدد لایهبندیشده (همگامسازی سبک <15s، همگامسازی کامل <60s)
minimize به روکش شناور و Android OS Picture-in-Picture
سفارشیسازی تم و i18n داخلی (EN/AR)
جایگزینی کامل بخشها (هدر، پیامها، کنترلها، پسزمینه، صندلیها)
توکنهای امضاشده در سرور: بکاند شما میسازد و کیت یک tokenProvider میگیرد
< utd_audio_room_kit />
شروع کنید
نصب
flutter pub add utd_audio_room_kitمشاهده در pub.dev
اتاقهای صوتی زندهٔ آمادهٔ استفاده با صندلیها، چت بیدرنگ و مدیریت محتوا.
< utd_audio_room_kit />
مرجع API
Main widget
The drop-in prebuilt audio-room widget that hosts the full UI and connection lifecycle.
UTDAudioRoomwidgetconst 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()?پیشفرض = nullAsync admin-list source; triggers a non-blocking self-upgrade if it lists the local user.
adminIdsNowSet<String> Function()?پیشفرض = nullSync 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?پیشفرض = nullOptional externally-owned controller (e.g. when restoring from minimize).
onControllerReadyvoid Function(UTDRoomController)?پیشفرض = nullCalled once the controller is created/attached.
onConnectionChangedvoid Function(bool isConnected)?پیشفرض = nullFired on connect success/failure.
onSeatTapvoid Function(int index, SeatState seat)?پیشفرض = nullCalled when a seat is tapped.
onSeatChangedvoid Function(List<SeatState> seats)?پیشفرض = nullCalled whenever seat state changes.
onConnectErrorvoid Function(Object error, StackTrace)?پیشفرض = nullCalled when the initial connect fails.
Room controller
Top-level controller owning connection, sub-controllers, roles, bans and speaker flows.
UTDRoomControllerconstructorUTDRoomController()Creates the controller and its seat, media, chat, minimize and PiP sub-controllers. Usually created internally by UTDAudioRoom.
initApimethodvoid 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.defaultBaseUrlIn-room engine host for seat/speaker/ban/role calls.
tokenBaseUrlStringپیشفرض = UTDApiClient.defaultTokenBaseUrlEdge host used for token generation.
appIdString?پیشفرض = nullEngine app ID.
appKeyStringالزامیPublishable app key sent as X-App-Key. Mint user tokens on your backend instead (see tokenProvider).
connectmethodasyncFuture<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پیشفرض = 9Number of seats to initialize.
enableMicOnJoinboolپیشفرض = falsePublish the local mic on connect.
useSpeakerboolپیشفرض = truePrefer Bluetooth/loudspeaker output on join.
userAttributesMap<String,String>پیشفرض = const {}Cosmetic participant attributes (avatar/frame/etc.).
roomNameString?پیشفرض = nullRoom name used for seat API calls.
مقدار بازگشتی: Future<void>
generateTokenmethodasyncFuture<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?پیشفرض = nullDisplay name.
seatCountint?پیشفرض = nullInitial seat count (host only).
modeIdString?پیشفرض = nullRoom mode id (host only).
مقدار بازگشتی: Future<UTDTokenResponse>
leavemethodasyncFuture<void> leave()Leaves the room: tears down listeners, drains any pending mic publish, disconnects the media room, and resets minimize/PiP state.
مقدار بازگشتی: Future<void>
changeRolemethodasyncFuture<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>
banUsermethodasyncFuture<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?پیشفرض = nullOptional ban reason.
durationSecondsint?پیشفرض = nullBan duration; null = permanent.
globalboolپیشفرض = falseTrue for a project-wide ban.
مقدار بازگشتی: Future<bool>
lockCommentsmethodasyncFuture<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>
requestToSpeakmethodasyncFuture<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>?>
inviteToSpeakmethodasyncFuture<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?پیشفرض = nullTarget seat the invitee is seated on if accepted.
مقدار بازگشتی: Future<Map<String,dynamic>?>
isConnectedgetterbool get isConnectedTrue when the room connection state is connected.
مقدار بازگشتی: bool
isHostOrAdmingetterbool get isHostOrAdminWhether the local participant's role is host or admin.
مقدار بازگشتی: bool
participantsStreamgetterasyncStream<List<UTDParticipant>> get participantsStreamStream of all room participants, emitting on join/leave/attribute/metadata changes.
مقدار بازگشتی: Stream<List<UTDParticipant>>
roleChangeStreamgetterasyncStream<UTDRoleChangeEvent> get roleChangeStreamStream of role changes for all participants (promotions, demotions, engine auto-corrections).
مقدار بازگشتی: Stream<UTDRoleChangeEvent>
activeSpeakerspropertyfinal ValueNotifier<Set<String>> activeSpeakersReactive set of identities currently speaking, polled from the media engine every 300ms.
مقدار بازگشتی: ValueNotifier<Set<String>>
commentsLockedpropertyfinal ValueNotifier<bool> commentsLockedReactive whether room chat is currently locked (server-driven; never set optimistically).
مقدار بازگشتی: ValueNotifier<bool>
onBannedcallbackvoid Function(UTDBanNotice notice)? onBannedFired once when the local user is banned from any source (data message, removal, or token 403). Wired internally by UTDAudioRoom.
مقدار بازگشتی: void Function(UTDBanNotice)?
disposemethodvoid 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.
UTDSeatControllerclassUTDSeatController(UTDRoomManager roomManager)Manages reactive seat state. Mutations call the REST API; local state updates only from _seat_update data messages or room _seats metadata.
takeSeatmethodasyncFuture<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>
leaveSeatmethodasyncFuture<bool> leaveSeat(String userId)Leaves the user's current seat via the API.
پارامترها
userIdStringالزامیIdentity leaving the seat.
مقدار بازگشتی: Future<bool>
moveSeatmethodasyncFuture<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>
lockSeatmethodasyncFuture<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>
kickFromSeatmethodasyncFuture<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>
setupSeatsmethodasyncFuture<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?پیشفرض = nullNew room mode id.
مقدار بازگشتی: Future<bool>
seatspropertyfinal ValueNotifier<List<SeatState>> seatsReactive list of all seat states.
مقدار بازگشتی: ValueNotifier<List<SeatState>>
pendingRequestspropertyfinal ValueNotifier<List<SpeakerRequest>> pendingRequestsReactive list of pending speaker requests (for host/admin UI).
مقدار بازگشتی: ValueNotifier<List<SpeakerRequest>>
getSeatIndexByUserIdmethodint getSeatIndexByUserId(String userId)Returns the seat index occupied by a user, or -1 if not seated.
پارامترها
userIdStringالزامیIdentity to look up.
مقدار بازگشتی: int
isSeatAvailablemethodbool 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?پیشفرض = nullUser to evaluate reservations against.
مقدار بازگشتی: bool
Media control
Mic, camera, speaker and Bluetooth-routing controls, kept in sync with server/host-side mutes.
UTDMediaControllerclassUTDMediaController(UTDRoomManager roomManager)Controls mic, camera and speaker state and listens to the engine's mute/permission events to keep reactive state authoritative.
setMicrophoneEnabledmethodasyncFuture<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>
toggleMicrophonemethodasyncFuture<void> toggleMicrophone()Toggles the local microphone on/off.
مقدار بازگشتی: Future<void>
applyBluetoothAudioRoutingmethodasyncFuture<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>
setSpeakerOnmethodasyncFuture<void> setSpeakerOn(bool on)Routes audio to the loudspeaker (true) or earpiece (false).
پارامترها
onboolالزامیSpeakerphone on/off.
مقدار بازگشتی: Future<void>
muteAllRemoteAudiomethodvoid muteAllRemoteAudio(bool mute)Mutes/unmutes playback of all remote participants' audio (and enforces it on late-subscribed tracks).
پارامترها
muteboolالزامیWhether to mute remote audio.
isMicEnabledpropertyfinal ValueNotifier<bool> isMicEnabledReactive local mic state, kept in sync with track mute/unmute events.
مقدار بازگشتی: ValueNotifier<bool>
canPublishpropertyfinal ValueNotifier<bool> canPublishReactive 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.
UTDChatControllerclassUTDChatController(UTDRoomManager roomManager)Sends and receives room chat over the data channel, enforcing the comment-lock gate and capping retained messages at 300.
sendMessagemethodasyncFuture<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>?پیشفرض = nullOptional extra payload attached to the message.
مقدار بازگشتی: Future<void>
addDisplayMessagemethodvoid addDisplayMessage(UTDChatMessage message)Appends a message to the local list without sending it (used for system lines).
پارامترها
messageUTDChatMessageالزامیMessage to display locally.
clearMessagesmethodvoid clearMessages()Clears the local message list.
messagespropertyfinal ValueNotifier<List<UTDChatMessage>> messagesReactive 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.
UTDAudioRoomConfigconstructorconst 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پیشفرض = trueShow the default controls bar.
showSeatNamesboolپیشفرض = trueShow occupant names under seats.
enableMinimizeboolپیشفرض = trueAllow minimizing the room to a floating overlay.
turnOnMicrophoneWhenJoiningboolپیشفرض = falsePublish the mic on join.
useSpeakerWhenJoiningboolپیشفرض = truePrefer speaker/Bluetooth output on join.
hostSeatIndexintپیشفرض = 0Seat index reserved for the host.
themeUTDRoomThemeپیشفرض = const UTDRoomTheme()Color tokens for the default UI.
stringsUTDRoomStrings?پیشفرض = nullLocalized strings; null = English defaults.
autoHostMicboolپیشفرض = trueAuto-enable the host's mic even if join-mic is false.
autoSeatHostboolپیشفرض = trueAuto-seat the host on hostSeatIndex if empty.
headerWidgetWidget?پیشفرض = nullCustom header replacing the default.
seatBuilderWidget Function(SeatState, double)?پیشفرض = nullCustom builder for a seat slot.
avatarBuilderWidget Function(String,double,Map<String,String>,bool,int,String)?پیشفرض = nullCustom occupant avatar builder.
userInRoomAttributesMap<String,String>پیشفرض = const {}Cosmetic attributes published to other participants.
UTDAudioRoomConfig.hostconstructorfactory UTDAudioRoomConfig.host()Factory preset for a host (microphone on when joining).
resolveStringsmethodUTDRoomStrings resolveStrings()Returns the configured strings or the English defaults.
مقدار بازگشتی: UTDRoomStrings
UTDRoomThemeconstructorconst 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.
copyWithmethodUTDRoomTheme copyWith({Color? background, Color? primary, Color? danger, ...})Returns a copy of the theme overriding only the supplied color tokens.
مقدار بازگشتی: UTDRoomTheme
UTDRoomStrings.enconstructorfactory UTDRoomStrings.en()English defaults for all built-in UI labels (seat actions, requests, host panels, comment-lock, templated lines).
UTDRoomStrings.arconstructorfactory UTDRoomStrings.ar()Arabic defaults for all built-in UI labels.
UTDMinimizeConfigconstructorconst 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?پیشفرض = nullCalled when the room is closed from the overlay.
overlayBuilderMiniOverlayBuilder?پیشفرض = nullCustom floating-overlay builder.
enableOSPipboolپیشفرض = falseEnable Android 12+ system PiP in addition to the overlay.
pipAspectWidthintپیشفرض = 1PiP aspect ratio numerator.
pipAspectHeightintپیشفرض = 1PiP aspect ratio denominator.
Models & enums
Data models for seats, room modes, chat and connection state.
SeatStateclassconst 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?پیشفرض = nullOccupant identity; null = empty.
isLockedboolپیشفرض = falseWhether the seat is admin-locked.
isMutedboolپیشفرض = falseWhether the occupant's mic is muted.
reservedForString?پیشفرض = nullIdentity this seat is reserved for.
attributesMap<String,String>پیشفرض = const {}Occupant cosmetic attributes (avatar, frame, etc.).
SpeakerRequestclassconst 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?پیشفرض = nullCreation timestamp.
RoomSeatStateclassconst 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?پیشفرض = nullRoom mode id.
seatsList<SeatState>الزامیPer-seat states.
requestsList<SpeakerRequest>الزامیPending speaker requests.
UTDRoomModeclassconst 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?پیشفرض = nullExplicit seat size override.
containerBuilderUTDSeatContainerBuilder?پیشفرض = nullCustom seat-grid container builder.
backgroundBuilderUTDBackgroundBuilder?پیشفرض = nullMode-specific background builder.
computeSeatSizemethoddouble 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.defaultModefieldstatic const UTDRoomMode defaultModeBuilt-in default mode: id '3', 9 seats in a 1-4-4 layout.
مقدار بازگشتی: UTDRoomMode
UTDChatMessageclassUTDChatMessage({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?پیشفرض = nullMessage id; auto-generated when omitted.
UTDConnectionStateenumenum 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)propertyfinal Future<UTDTokenResponse?> Function()? tokenProviderSupplies 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.
UTDTokenResponseclassclass 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)propertyFuture<UTDTokenResponse> Function()? tokenProviderToken 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.
autoRejoinEnabledpropertybool autoRejoinEnabled = trueWhether the kit redials by itself after a drop. Turn off only if your app owns recovery; rejoin() stays available.
autoRejoinMaxAttemptspropertyint autoRejoinMaxAttempts = 10How 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.
onRejoinFailedcallbackvoid Function()? onRejoinFailedCalled 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.
onForceExitcallbackvoid Function()? onForceExitCalled 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.
rejoinmethodasyncFuture<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.
chatBannedpropertyfinal ValueNotifier<bool> chatBannedTrue 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.
UTDChatBanListclassclass UTDChatBanListThe room's chat-ban list as the kit reads it from room metadata. Exported if you want to read it yourself.
utdErrorCodeOfmethodString 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'.
utdErrorInfomethodUTDErrorInfo 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.
UTDErrorInfoclassclass 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.
UTDErrorActionenumenum 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.
lastSeatErrorpropertyfinal ValueNotifier<UTDSeatError?> lastSeatErrorWhy 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.
UTDSeatErrorclassclass 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 بسازید؟
حساب خود را بسازید، کیف پول اصلیتان را شارژ کنید و سرویسهایی را که نیاز دارید روشن کنید.