< Flutter UIKit />
UTD Calls Kit
تماسهای صوتی و تصویری آمادهٔ 1:1 با رابط تماس بومی و push.
import 'package:utd_calls_kit/utd_calls_kit.dart';
UTDCallView(
config: UTDCallsConfig(
appId: '<utd-app-id>',
appKey: '<utd-app-key>', // publishable; no backend needed
userId: 'user123',
userName: 'Sara',
enableCallKit: true, // OS-native incoming-call UI
enablePush: true, // VoIP/FCM wake-from-killed
),
onControllerReady: (c) => c.startCall(
'user-99', name: 'Omar', type: UTDStreamType.videoCall,
),
);1:1
صوتی و تصویری
LiveKit
موتور
Drop-in
رابط کامل
CallKit
+ push VoIP
< utd_calls_kit />
ویژگیهای کلیدی
یک پکیج آمادهٔ Flutter برای تماسهای صوتی و تصویری 1:1 که توسط LiveKit و UTD Stream Engine پشتیبانی میشود. صفحههای آمادهٔ تماس خروجی، ورودی و حین تماس با رابط تماس بومی سیستمعامل (CallKit/ConnectionService)، بیدارسازی از حالت kill شده با VoIP/FCM، مسیریابی بلندگو/گوشی/Bluetooth، خاموشکردن صفحه با حسگر مجاورت، کوچکسازی و Picture-in-Picture اندروید — بدون نیاز به سرور توکن بکاند.
رابط کاربری آمادهٔ تماس: صفحههای خروجی، ورودی و حین تماس — بدون کد اضافه
تماس صوتی و تصویری 1:1 با ارتقای زندهٔ صوت↔تصویر حین تماس
رابط تماس ورودی بومی سیستمعامل: CallKit (iOS) و ConnectionService (Android)
بیدارسازی از حالت kill شده با VoIP/FCM همراه با پذیرش و ازسرگیری در راهاندازی سرد
کنترلهای رسانه: میکروفون، دوربین، مسیریابی بلندگو/گوشی/Bluetooth
خاموشکردن صفحه با حسگر مجاورت هنگام تماس صوتی نزدیک گوش
کوچکسازی به پوشش شناور و Picture-in-Picture اندروید
سفارشیسازی تم و i18n داخلی (EN/AR)
بدون سرور توکن بکاند — صدور توکن مبتنی بر appKey
< utd_calls_kit />
شروع کنید
نصب
flutter pub add utd_calls_kit< utd_calls_kit />
مرجع API
Main widget & screens
The UTDCallView entry widget that owns the call controller and routes to the default outgoing, incoming, and in-call screens based on the current call phase.
UTDCallViewwidgetconst UTDCallView({Key? key, required UTDCallsConfig config, UTDCallController? controller, void Function(UTDCallController controller)? onControllerReady, bool autoInit = true, WidgetBuilder? idleBuilder})The calls kit entry widget. Takes a UTDCallsConfig, owns a UTDCallController (or adopts one passed in), wires the UTDCallsScope, and renders the right default screen for the current call phase. On mount it builds the controller and (unless autoInit is false) calls UTDCallController.init to mint the bearer and connect the signal WebSocket, then invokes onControllerReady so the host can call startCall / acceptIncoming / wire onIncomingCall / onCallEnded. Routes UTDCallPhase.outgoing|connecting to UTDOutgoingCallScreen, incoming to UTDIncomingCallScreen, active|reconnecting to UTDInCallScreen, and idle|ended to idleBuilder (or an empty SizedBox).
پارامترها
keyKey?Standard Flutter widget key forwarded to super.
configUTDCallsConfigالزامیImmutable configuration (credentials, hosts, identity, theme, strings) used to build the controller and the UTDCallsScope.
controllerUTDCallController?پیشفرض = nullAn externally-owned controller to adopt. When null, UTDCallView creates and owns one (and disposes it on unmount).
onControllerReadyvoid Function(UTDCallController controller)?پیشفرض = nullCalled once the controller is built (and init() started when autoInit), so the host can drive calls or wire callbacks.
autoInitboolپیشفرض = trueWhether to call UTDCallController.init automatically on mount.
idleBuilderWidgetBuilder?پیشفرض = nullWhat to render when there is no call in progress (idle / ended). Defaults to an empty SizedBox so the host controls navigation.
configfieldfinal UTDCallsConfig configImmutable configuration (credentials, hosts, identity, theme, strings).
controllerfieldfinal UTDCallController? controllerAn externally-owned controller to adopt. When null, UTDCallView creates and owns one (and disposes it on unmount).
onControllerReadyfieldfinal void Function(UTDCallController controller)? onControllerReadyCalled once the controller is built (and init() started when autoInit).
autoInitfieldfinal bool autoInitWhether to call UTDCallController.init automatically on mount.
idleBuilderfieldfinal WidgetBuilder? idleBuilderWhat to render when there is no call in progress (idle / ended). Defaults to an empty SizedBox so the host controls navigation.
UTDCallView.createStatemethodState<UTDCallView> createState()Creates the private state object backing UTDCallView; not for direct use.
مقدار بازگشتی: State<UTDCallView> — The internal state that builds the controller and renders the phase screen.
UTDOutgoingCallScreenwidgetconst UTDOutgoingCallScreen({Key? key, required UTDCallState state})Default outgoing-call screen: the peer avatar/name, a 'Ringing…' status (or 'Connecting…' before the room is live), and a cancel button that calls controller.end. Reads theme/strings/controller from the surrounding UTDCallsScope. Shown while UTDCallState.phase is UTDCallPhase.outgoing or connecting.
پارامترها
keyKey?Standard Flutter widget key forwarded to super.
stateUTDCallStateالزامیThe current immutable call snapshot driving the displayed peer label and status.
UTDOutgoingCallScreen.statefieldfinal UTDCallState stateThe current immutable call snapshot driving the displayed peer label and ringing/connecting status.
UTDOutgoingCallScreen.buildmethodWidget build(BuildContext context)Builds the outgoing-call UI: avatar, peer name, ringing/connecting status text, and a cancel control wired to controller.end.
مقدار بازگشتی: Widget — The rendered outgoing-call screen.
UTDIncomingCallScreenwidgetconst UTDIncomingCallScreen({Key? key, required UTDCallState state})Default incoming-call screen: the caller avatar/name, a call-type subtitle (incoming video vs voice based on UTDCallState.type), and accept/decline actions wired to controller.acceptIncoming and controller.reject. Reads theme/strings/controller from the surrounding UTDCallsScope. Shown while UTDCallState.phase is UTDCallPhase.incoming.
پارامترها
keyKey?Standard Flutter widget key forwarded to super.
stateUTDCallStateالزامیThe current immutable call snapshot driving the caller label and call-type subtitle.
UTDIncomingCallScreen.statefieldfinal UTDCallState stateThe current immutable call snapshot driving the caller label and call-type subtitle.
UTDIncomingCallScreen.buildmethodWidget build(BuildContext context)Builds the incoming-call UI: avatar, caller name, voice/video subtitle, and decline/accept controls wired to controller.reject and controller.acceptIncoming.
مقدار بازگشتی: Widget — The rendered incoming-call screen.
UTDInCallScreenwidgetconst UTDInCallScreen({Key? key, required UTDCallState state})Default in-call screen. For a voice call it shows the peer avatar/name, a live timer, a reconnecting banner and a mute/camera/speaker/minimize/end control bar. For a video call it renders the remote video full-screen with a draggable local self-view PiP tile. A proximity overlay blanks the screen while a voice call is held to the ear (earpiece route). Reads theme/strings/controller from the surrounding UTDCallsScope. Shown while UTDCallState.phase is UTDCallPhase.active or reconnecting.
پارامترها
keyKey?Standard Flutter widget key forwarded to super.
stateUTDCallStateالزامیThe current immutable call snapshot driving the timer, video vs audio stage, and reconnecting banner.
UTDInCallScreen.statefieldfinal UTDCallState stateThe current immutable call snapshot driving the timer, audio/video stage and reconnecting banner.
UTDInCallScreen.createStatemethodState<UTDInCallScreen> createState()Creates the private stateful object that drives the per-second timer ticker and tracks the draggable PiP offset; not for direct use.
مقدار بازگشتی: State<UTDInCallScreen> — The internal state managing the live-duration ticker and self-view PiP position.
UTDCallPhaseenumThe high-level phase of a 1:1 call, driving which default screen UTDCallView shows. Values: idle (no call), outgoing (we created it and are ringing the callee), incoming (callee side before accept/decline), connecting (joining the media room post-accept), active (both parties in the room), reconnecting (transport dropped and auto-reconnecting), ended (terminal state). UTDCallView routes outgoing/connecting to the outgoing screen, incoming to the incoming screen, active/reconnecting to the in-call screen, and idle/ended to idleBuilder.
Call controller
UTDCallController is the ChangeNotifier orchestrator that owns the transport and active session, drives the 1:1 call lifecycle, and exposes reactive state plus media/audio-route/proximity/minimize/pip sub-controllers.
UTDCallControllerclassUTDCallController(UTDCallsConfig config)The single source of truth for a 1:1 call. A ChangeNotifier that owns the transport (UTDCallsClient) and the active UTDCallSession, drives the call lifecycle, and exposes one reactive state for the default UI plus a few ValueNotifier surfaces for fine-grained binding. A static activeController guard prevents two concurrent calls from fighting over the audio device.
پارامترها
configUTDCallsConfigالزامیThe kit configuration. Also constructs the internal UTDCallsClient transport from it and gates push/CallKit/minimize behavior.
configfieldfinal UTDCallsConfig configThe kit configuration passed to the constructor (final UTDCallsConfig).
activeControllergetterstatic UTDCallController? get activeControllerStatic getter returning the controller that currently owns an active/ringing call, or null when none is active.
مقدار بازگشتی: UTDCallController? — The currently active controller, or null.
hasActiveCallgetterstatic bool get hasActiveCallStatic getter for whether any call is currently in progress (true when the active controller's state.isInCall is true).
مقدار بازگشتی: bool — True if a call is in progress.
mediafieldfinal UTDCallMediaController mediaThin mic/camera/speaker passthrough sub-controller, rebound to each call's room (final UTDCallMediaController).
audioRoutefieldfinal UTDAudioRouteController audioRouteSpeaker/earpiece/bluetooth output routing sub-controller, rebound to each call's room (final UTDAudioRouteController).
proximityfieldfinal UTDProximityController proximityProximity-based screen blanking sub-controller for an earpiece voice call (final UTDProximityController).
minimizefieldlate final UTDCallMinimizeController minimizeIn-app minimize (floating overlay) orchestration sub-controller; drives enableMinimize (late final UTDCallMinimizeController, created with this controller).
pipfieldlate final UTDCallPipController pipAndroid OS-level Picture-in-Picture orchestration sub-controller (no-op off Android; late final UTDCallPipController, created with this controller).
callStatefieldfinal ValueNotifier<UTDCallState> callStateThe current call snapshot as a reactive ValueNotifier; also mirrored to listeners via notifyListeners (final ValueNotifier<UTDCallState>).
pendingInvitationfieldfinal ValueNotifier<UTDCallInvitation?> pendingInvitationIncoming calls not yet answered (callee side) as a reactive ValueNotifier; drives an incoming-call UI even before the host routes to the call screen (final ValueNotifier<UTDCallInvitation?>).
stategetterUTDCallState get stateThe current call snapshot, a convenience getter over callState.value.
مقدار بازگشتی: UTDCallState — The current call state snapshot.
onIncomingCallfieldvoid Function(UTDCallInvitation invitation)? onIncomingCallCallback invoked when an incoming call arrives (callee side) while no call is active. The host typically navigates to the incoming-call screen here.
onCallEndedfieldvoid Function(UTDCallState finalState)? onCallEndedCallback invoked once when the call reaches a terminal state. The host typically pops the call screen here.
initmethodasyncFuture<void> init()Initialize the transport: mint the bearer and connect the signal WS, then start listening for incoming calls and call updates. Configures minimize and starts the CallKit bridge when enabled, and resumes a cold-started accepted call when push + CallKit are enabled. Call once at startup; no-op after dispose.
مقدار بازگشتی: Future<void> — Completes once transport is initialized and listeners are attached.
startCallmethodasyncFuture<void> startCall(String calleeId, {String? name, UTDStreamType type = UTDStreamType.audioCall})Caller: start a call to calleeId. Claims the active-controller guard, joins the media room and rings the callee; moves state to UTDCallPhase.outgoing, then active when the callee accepts/joins. No-op if a call is already in progress; rethrows UTDStreamException after terminating on failure.
پارامترها
calleeIdStringالزامیThe identity of the user to call.
nameString?Optional display name for the callee, used in the call UI.
typeUTDStreamTypeپیشفرض = UTDStreamType.audioCallThe call type (audio or video); a video call defaults the speaker on.
مقدار بازگشتی: Future<void> — Completes once the call has been created server-side and the room joined.
acceptIncomingmethodasyncFuture<void> acceptIncoming()Callee: accept the pending incoming call. Claims the active-controller guard, clears the pending invitation, joins the media room and moves to UTDCallPhase.connecting then active. No-op when there is no pending invitation; rethrows UTDStreamException after terminating on failure.
مقدار بازگشتی: Future<void> — Completes once the call is accepted and the room joined.
rejectmethodasyncFuture<void> reject()Callee: reject the pending incoming call (no media room is joined). Dismisses the native UI, sends the reject signal best-effort, and resets to idle. No-op when there is no pending invitation.
مقدار بازگشتی: Future<void> — Completes once the reject signal is sent and local state is reset.
endmethodasyncFuture<void> end()Hang up the current call (or cancel an outgoing one). Ends it server-side, tears down the media room, and terminates with cancelled (outgoing not yet joined) or localHangup otherwise.
مقدار بازگشتی: Future<void> — Completes once the call is ended server-side and the session is torn down.
toggleMicmethodasyncFuture<void> toggleMic()Toggle the local microphone (delegates to media.toggleMicrophone).
مقدار بازگشتی: Future<void> — Completes once the mic state is toggled.
toggleCameramethodasyncFuture<void> toggleCamera()Toggle the local camera (delegates to media.toggleCamera). Enabling on a voice call performs a live audio→video upgrade in the same room (no reconnect).
مقدار بازگشتی: Future<void> — Completes once the camera state is toggled.
flipCameramethodasyncFuture<void> flipCamera()Switch between the front and back camera, video calls only (delegates to media.flipCamera).
مقدار بازگشتی: Future<void> — Completes once the camera is flipped.
toggleSpeakermethodasyncFuture<void> toggleSpeaker()Toggle the loudspeaker (delegates to media.toggleSpeaker).
مقدار بازگشتی: Future<void> — Completes once the speaker state is toggled.
cycleAudioRoutemethodasyncFuture<void> cycleAudioRoute()Cycle the audio output route earpiece → speaker → bluetooth → earpiece (delegates to audioRoute.cycle).
مقدار بازگشتی: Future<void> — Completes once the route is cycled.
setAudioRoutemethodasyncFuture<void> setAudioRoute(UTDAudioRoute route)Route audio to the given route — earpiece, speaker, or bluetooth (delegates to audioRoute.setRoute).
پارامترها
routeUTDAudioRouteالزامیThe target audio output route (earpiece / speaker / bluetooth).
مقدار بازگشتی: Future<void> — Completes once the route is applied.
unregisterPushmethodasyncFuture<void> unregisterPush()Unregister this device's push token (e.g. on sign-out). Best-effort; delegates to the transport client.
مقدار بازگشتی: Future<void> — Completes once the unregister request is sent.
disposemethodvoid dispose()Tear down the controller: cancel all subscriptions, end and dispose any active session and the CallKit bridge, dispose the media/audioRoute/proximity/pip sub-controllers and transport client, and dispose the reactive notifiers. Idempotent; overrides ChangeNotifier.dispose.
Media, audio routing & PiP
Runtime call-control sub-controllers for mic/camera/speaker, audio-route selection, proximity screen-blanking, in-app minimize, and Android OS Picture-in-Picture.
UTDCallMediaControllerclassUTDCallMediaController()Thin mic/camera/speaker passthrough to the active call's UTDRoom. The room is rebindable: each new call gets a fresh UTDRoom and the controller is re-pointed via bind(). State is mirrored from the room's own ValueNotifiers, which flip only when the SFU confirms (never optimistically).
isMicEnabledfieldfinal ValueNotifier<bool> isMicEnabledWhether the local mic is currently publishing (mirrors the room). Starts false.
isCameraEnabledfieldfinal ValueNotifier<bool> isCameraEnabledWhether the local camera is currently publishing (mirrors the room). Starts false.
isSpeakerOnfieldfinal ValueNotifier<bool> isSpeakerOnWhether audio is routed to the loudspeaker (mirrors the room). Starts false.
roomgetterUTDRoom? get roomThe bound room, or null before the first bind(). Exposed so the UI can render local/remote video tracks via the LiveKit room.
bindmethodvoid bind(UTDRoom room)Point the controller at the call's room and start mirroring its mic/camera/speaker state. Replaces any previous binding.
پارامترها
roomUTDRoomالزامیThe live room to mirror state from.
unbindmethodvoid unbind()Stop mirroring the current room (e.g. on call end) without disposing it — the session owns the room's lifecycle.
toggleMicrophonemethodasyncFuture<void> toggleMicrophone()Toggle the local microphone (calls setMicrophoneEnabled with the inverse of isMicEnabled).
مقدار بازگشتی: Future<void> — Completes once the mic request is sent to the room.
setMicrophoneEnabledmethodasyncFuture<void> setMicrophoneEnabled(bool enabled)Set the local microphone to enabled. Gated by the room on the publish grant; isMicEnabled flips only after the SFU confirms. No-op when no room is bound.
پارامترها
enabledboolالزامیWhether the mic should publish.
مقدار بازگشتی: Future<void> — Completes once the request reaches the room.
toggleCameramethodasyncFuture<void> toggleCamera()Toggle the local camera. Enabling on an audio call performs a live audio→video upgrade in the same room (no reconnect).
مقدار بازگشتی: Future<void> — Completes once the camera request is sent.
setCameraEnabledmethodasyncFuture<void> setCameraEnabled(bool enabled)Set the local camera to enabled. Gated by the room on the publish grant; isCameraEnabled flips only after the SFU confirms. No-op when no room is bound.
پارامترها
enabledboolالزامیWhether the camera should publish.
مقدار بازگشتی: Future<void> — Completes once the request reaches the room.
flipCameramethodasyncFuture<void> flipCamera()Switch between the front and back camera. No-op when the camera is off.
مقدار بازگشتی: Future<void> — Completes once the camera is switched.
toggleSpeakermethodasyncFuture<void> toggleSpeaker()Toggle the loudspeaker (calls setSpeakerOn with the inverse of isSpeakerOn).
مقدار بازگشتی: Future<void> — Completes once the speaker request is sent.
setSpeakerOnmethodasyncFuture<void> setSpeakerOn(bool on)Route audio to the loudspeaker (on) or back to the earpiece/Bluetooth. No-op when no room is bound.
پارامترها
onboolالزامیTrue for loudspeaker, false for earpiece/Bluetooth.
مقدار بازگشتی: Future<void> — Completes once the request reaches the room.
applyBluetoothAudioRoutingmethodasyncFuture<void> applyBluetoothAudioRouting()Apply the Android Bluetooth-routing fix; call after connect + mic publish.
مقدار بازگشتی: Future<void> — Completes once the routing fix is applied.
disposemethodvoid dispose()Unbind and dispose the mic/camera/speaker notifiers. Idempotent.
UTDAudioRouteenumenum UTDAudioRoute { earpiece, speaker, bluetooth }The audio output destination for a call. Values: earpiece (the phone's in-ear receiver, the default for a voice call held to the ear), speaker (the loudspeaker), bluetooth (a connected Bluetooth headset).
UTDAudioRouteControllerclassUTDAudioRouteController()Drives a call's audio output routing on top of UTDRoom's low-level setSpeakerOn / setSpeakerPreferBluetooth / applyBluetoothAudioRouting. The room is rebindable per call via bind(). The route notifier reflects the last requested destination; the room's speaker flag is mirrored back so route and room stay consistent.
routefieldfinal ValueNotifier<UTDAudioRoute> routeThe currently selected output route. Defaults to UTDAudioRoute.earpiece — the right default for a 1:1 voice call. A platform-confirmed speaker flip from the room reconciles this (speaker-on ⇒ speaker, speaker-off ⇒ earpiece), while a bluetooth selection is preserved.
bindmethodvoid bind(UTDRoom room)Point the controller at the call's room and start mirroring its speaker state. Replaces any previous binding and resets the route to the earpiece.
پارامترها
roomUTDRoomالزامیThe live room to mirror speaker state from.
unbindmethodvoid unbind()Stop mirroring the current room without disposing it (the session owns the room lifecycle).
setRoutemethodasyncFuture<void> setRoute(UTDAudioRoute target)Route audio to target. earpiece/speaker toggle the loudspeaker; bluetooth prefers a connected headset and applies the Android communication-mode fix. Updates route immediately, then applies to the room. No-op when no room is bound.
پارامترها
targetUTDAudioRouteالزامیThe desired output destination.
مقدار بازگشتی: Future<void> — Completes once the route change is applied to the room.
cyclemethodasyncFuture<void> cycle()Cycle earpiece → speaker → bluetooth → earpiece. A convenience for a single tri-state control button.
مقدار بازگشتی: Future<void> — Completes once the next route is applied.
applyBluetoothAudioRoutingmethodasyncFuture<void> applyBluetoothAudioRouting()Apply the preferred Bluetooth routing after connect + publish. Safe to re-call on device changes / reconnect. Leaves route unchanged unless a headset is the active destination.
مقدار بازگشتی: Future<void> — Completes once the routing is applied.
disposemethodvoid dispose()Unbind and dispose the route notifier. Idempotent.
UTDProximityControllerclassUTDProximityController()Toggles the phone's proximity-based screen blanking for the duration of a voice call. Active only while it is a voice call AND audio is on the earpiece; suppressed when the loudspeaker comes on or on any video call. All platform calls are best-effort — a device with no proximity sensor simply never reports near.
isNearfieldfinal ValueNotifier<bool> isNearWhether the proximity sensor currently reports the device is near (held to the ear). The UI binds to this to paint a black, input-absorbing overlay. Starts false.
updatemethodvoid update({required bool isVoiceCall, required bool speakerOn})Recompute whether proximity blanking should run for the current call. Blanking runs only when it is a voice call held to the earpiece (isVoiceCall && !speakerOn), starting or stopping the sensor accordingly.
پارامترها
isVoiceCallboolالزامیFalse for video calls (where the user needs to see the picture).
speakerOnboolالزامیTrue when audio is routed to the loudspeaker or a Bluetooth headset.
disposemethodvoid dispose()Stop the sensor and dispose the isNear notifier. Idempotent.
UTDCallMiniOverlayStateenumenum UTDCallMiniOverlayState { idle, inCall, minimizing }The minimize state of a call. Values: idle (no active overlay), inCall (call shown full-screen), minimizing (call shrunk to the floating overlay).
UTDCallMiniOverlayMachineclassUTDCallMiniOverlayMachine instanceProcess-wide singleton tracking whether the current call is on its full screen, minimized to the floating overlay, or idle. Access via the static UTDCallMiniOverlayMachine.instance (private constructor). Exposes stateNotifier, state, isMinimizing/isInCall/isIdle getters, and changeState(UTDCallMiniOverlayState).
UTDCallMinimizeControllerclassUTDCallMinimizeController(UTDCallController controller)In-app minimize orchestration for a call: captures the current named route, pops the call screen into a floating overlay, and restores it later. Backed by the UTDCallMiniOverlayMachine singleton.
پارامترها
controllerUTDCallControllerالزامیThe call controller whose call is minimized/restored/ended.
isMinimizinggetterbool get isMinimizingWhether a call is currently minimized to the overlay (proxies the overlay machine).
stateNotifiergetterValueNotifier<UTDCallMiniOverlayState> get stateNotifierThe minimize-state notifier from the underlying overlay machine; bind UI to react to idle/inCall/minimizing transitions.
configgetterUTDCallMinimizeConfig? get configThe minimize configuration set via configure(), or null if not yet configured.
datagetterUTDCallMinimizeData? get dataThe captured navigation snapshot (controller + route name + arguments), or null when no minimize is active.
configuremethodvoid configure(UTDCallMinimizeConfig config)Set the overlay/PiP configuration used when minimizing.
پارامترها
configUTDCallMinimizeConfigالزامیThe minimize/PiP configuration.
captureNavigationmethodvoid captureNavigation(BuildContext context)Snapshot the current Navigator and modal route (name + arguments) so the call screen can later be restored.
پارامترها
contextBuildContextالزامیBuild context on the call screen route.
startMinimizemethodbool startMinimize(BuildContext context)Capture navigation, switch the machine to minimizing, and pop the call screen into the overlay. Returns false if already minimizing or not currently in a call.
پارامترها
contextBuildContextالزامیBuild context on the call screen route to pop.
مقدار بازگشتی: bool — True if the minimize started; false if it was a no-op.
restoremethodbool restore(BuildContext context)Bring the minimized call back full-screen by pushing the captured named route via Navigator.of(context). Returns false if not minimizing, no data, or no captured route name.
پارامترها
contextBuildContextالزامیA context with access to the target Navigator.
مقدار بازگشتی: bool — True if a restore was scheduled; false otherwise.
restoreWithNavigatormethodbool restoreWithNavigator()Restore the call screen using the NavigatorState captured at minimize time (no BuildContext needed, e.g. from the floating overlay). Returns false if not minimizing, no data, no captured navigator, or no route name.
مقدار بازگشتی: bool — True if a restore was scheduled; false otherwise.
closemethodasyncFuture<void> close()End the call, reset the machine to idle, invoke the config's onClose callback, and clear the captured navigation/data.
مقدار بازگشتی: Future<void> — Completes once the call has ended and state is reset.
dismissmethodvoid dismiss()Dismiss the overlay without ending the call or invoking onClose. Used internally when the controller tears a call down on its own.
UTDCallMinimizeConfigclassconst UTDCallMinimizeConfig({VoidCallback? onClose, UTDCallMiniOverlayBuilder? overlayBuilder, double overlayWidth = 110, double overlayHeight = 150, double overlayBottomOffset = 120, double overlayRightOffset = 16, double borderRadius = 16, bool showEndButton = true, bool enableOSPip = false, int pipAspectWidth = 9, int pipAspectHeight = 16})Configuration for minimizing a call to a floating in-app overlay and, optionally, an Android OS-level Picture-in-Picture window.
پارامترها
onCloseVoidCallback?Called when the overlay's end button is tapped (after the call is torn down). The host typically clears any call route here.
overlayBuilderUTDCallMiniOverlayBuilder?A fully custom overlay builder; when null the kit's default tile is used.
overlayWidthdoubleپیشفرض = 110Default overlay tile width (logical px).
overlayHeightdoubleپیشفرض = 150Default overlay tile height (logical px).
overlayBottomOffsetdoubleپیشفرض = 120Initial inset of the overlay from the bottom of the screen.
overlayRightOffsetdoubleپیشفرض = 16Initial inset of the overlay from the right of the screen.
borderRadiusdoubleپیشفرض = 16Corner radius of the default overlay tile.
showEndButtonboolپیشفرض = trueWhether the default overlay shows a small end-call button.
enableOSPipboolپیشفرض = falseEnables Android OS-level PiP in addition to the overlay. On Android 12+ the app auto-enters a system PiP window when backgrounded while on the call screen; iOS / Android < 31 ignore it.
pipAspectWidthintپیشفرض = 9Numerator of the PiP window aspect ratio; must satisfy Android's bounds (between 1/2.39 and 2.39/1) or PiP entry is skipped.
pipAspectHeightintپیشفرض = 16Denominator of the PiP window aspect ratio; defaults to a portrait 9:16 phone-call window.
UTDCallMiniOverlayBuildertypedeftypedef UTDCallMiniOverlayBuilder = Widget Function({required VoidCallback onRestore, required VoidCallback onClose})Builds a fully custom minimize overlay, overriding the kit's default. The host wires onRestore (bring the call screen back) and onClose (hang up).
UTDCallPipControllerclassUTDCallPipController(UTDCallController controller)Drives Android OS-level Picture-in-Picture for a call, alongside the in-app minimize overlay. On Android 12+ (API 31+) it delegates to the floating plugin's OnLeavePiP so the OS auto-enters a system PiP window when the app is backgrounded while on the call screen. Android-only: every method is a no-op on other platforms.
پارامترها
controllerUTDCallControllerالزامیThe call controller whose minimize config gates and configures PiP.
isInPipfieldfinal ValueNotifier<bool> isInPipTrue while the app is actually shrunk into the system PiP window. Starts false.
armIfEnabledmethodasyncFuture<void> armIfEnabled()Arms auto-enter-on-Home if PiP is enabled in config and supported by the device. Safe to call repeatedly. No-op on iOS, when disposed, when disabled in config, or when PiP is unavailable.
مقدار بازگشتی: Future<void> — Completes once arming is attempted.
setInPipmethodvoid setInPip(bool inPip)Reports the real OS PiP enter/exit transition. Driven by the host app's pip_state_channel handler forwarding MainActivity.onPictureInPictureModeChanged. Re-arms auto-enter on exit. No-op on iOS / Android < 31 / after dispose.
پارامترها
inPipboolالزامیTrue when entering the system PiP window, false when leaving it.
disarmmethodasyncFuture<void> disarm()Cancels auto-enter so backgrounding no longer triggers PiP and resets isInPip. No-op on iOS.
مقدار بازگشتی: Future<void> — Completes once auto-enter is cancelled.
disposemethodvoid dispose()Final teardown (call from UTDCallController.dispose). Cancels auto-enter and disposes isInPip; does NOT dispose the shared process-wide floating singleton. Idempotent.
Configuration
Immutable configuration objects for the calls kit: the top-level UTDCallsConfig (credentials, identity, hosts, theme/strings, feature flags) and UTDCallMinimizeConfig for tuning the minimize overlay and Android OS PiP.
UTDCallsConfigclassconst UTDCallsConfig({required String appId, required String appKey, required String userId, required String userName, String baseUrl = UTDApiClient.defaultBaseUrl, String tokenBaseUrl = UTDApiClient.defaultTokenBaseUrl, UTDCallsTheme theme = const UTDCallsTheme(), UTDCallsStrings? strings, bool enableMinimize = true, UTDCallMinimizeConfig? minimizeConfig, bool enableCallKit = true, bool enablePush = true})Immutable configuration for the calls kit. Carries the no-backend mint credentials (appId + the publishable appKey), the local user identity, the engine hosts, and the default-UI theme/strings/flags. One set of credentials works for every enabled call type; the type is chosen per call, never per credential. Extends Equatable.
پارامترها
appIdStringالزامیApp ID for the UTD Stream Engine (e.g. "9325906999").
appKeyStringالزامیThe project's publishable app key (the no-backend mint credential, sent as X-App-Key). The server secret never ships.
userIdStringالزامیThe local user's identity (the caller/callee identity on the engine).
userNameStringالزامیThe local user's display name.
baseUrlStringپیشفرض = UTDApiClient.defaultBaseUrlThe engine host for privileged in-call ops (Bearer). Grey-cloud origin.
tokenBaseUrlStringپیشفرض = UTDApiClient.defaultTokenBaseUrlThe mint host for POST /api/v1/token and /api/v1/signal/token (X-App-Key).
themeUTDCallsThemeپیشفرض = const UTDCallsTheme()Color tokens for the built-in default call UI.
stringsUTDCallsStrings?پیشفرض = const UTDCallsStrings()User-facing strings for the built-in default call UI. When null, a default UTDCallsStrings is used.
enableMinimizeboolپیشفرض = trueWhether the in-call screen may be minimized to a floating overlay (and, when minimizeConfig opts in, Android OS PiP).
minimizeConfigUTDCallMinimizeConfig?Tuning for the minimize overlay / OS PiP. When null a sensible default UTDCallMinimizeConfig is used. Excluded from equality (it may carry callbacks / custom builders).
enableCallKitboolپیشفرض = trueWhether incoming calls are shown on the OS-native call UI (CallKit on iOS, ConnectionService on Android) via UTDCallKitBridge. When false (or the platform/host is not configured), the in-app UTDIncomingCallScreen is the fallback.
enablePushboolپیشفرض = trueWhether the kit registers this device's push tokens with the engine and wakes the app from background/killed on an incoming call (iOS PushKit VoIP into CallKit, Android FCM {type:'call'} data messages). Requires the host's Firebase / PushKit + CallKit setup; degrades gracefully when not configured.
appIdfieldfinal String appIdApp ID for the UTD Stream Engine (e.g. "9325906999").
appKeyfieldfinal String appKeyThe project's publishable app key (the no-backend mint credential, sent as X-App-Key). The server secret never ships.
userIdfieldfinal String userIdThe local user's identity (the caller/callee identity on the engine).
userNamefieldfinal String userNameThe local user's display name.
baseUrlfieldfinal String baseUrlThe engine host for privileged in-call ops (Bearer). Grey-cloud origin.
tokenBaseUrlfieldfinal String tokenBaseUrlThe mint host for POST /api/v1/token + /api/v1/signal/token (X-App-Key).
themefieldfinal UTDCallsTheme themeColor tokens for the built-in default call UI.
stringsfieldfinal UTDCallsStrings stringsUser-facing strings for the built-in default call UI.
enableMinimizefieldfinal bool enableMinimizeWhether the in-call screen may be minimized to a floating overlay (and, when minimizeConfig opts in, Android OS PiP). Default true.
minimizeConfigfieldfinal UTDCallMinimizeConfig? minimizeConfigTuning for the minimize overlay / OS PiP. When null a sensible default (UTDCallMinimizeConfig) is used. Excluded from equality.
enableCallKitfieldfinal bool enableCallKitWhether incoming calls are shown on the OS-native call UI via UTDCallKitBridge. Default true.
enablePushfieldfinal bool enablePushWhether the kit registers device push tokens with the engine and wakes the app from background/killed on incoming calls. Default true.
copyWithmethodUTDCallsConfig copyWith({String? appId, String? appKey, String? userId, String? userName, String? baseUrl, String? tokenBaseUrl, UTDCallsTheme? theme, UTDCallsStrings? strings, bool? enableMinimize, UTDCallMinimizeConfig? minimizeConfig, bool? enableCallKit, bool? enablePush})Returns a copy of this config with the given fields replaced. Any omitted argument keeps the current value.
پارامترها
appIdString?Replacement app ID, or current value when omitted.
appKeyString?Replacement app key, or current value when omitted.
userIdString?Replacement user ID, or current value when omitted.
userNameString?Replacement display name, or current value when omitted.
baseUrlString?Replacement engine host, or current value when omitted.
tokenBaseUrlString?Replacement mint host, or current value when omitted.
themeUTDCallsTheme?Replacement theme, or current value when omitted.
stringsUTDCallsStrings?Replacement strings, or current value when omitted.
enableMinimizebool?Replacement minimize flag, or current value when omitted.
minimizeConfigUTDCallMinimizeConfig?Replacement minimize config, or current value when omitted.
enableCallKitbool?Replacement CallKit flag, or current value when omitted.
enablePushbool?Replacement push flag, or current value when omitted.
مقدار بازگشتی: UTDCallsConfig — A new config with the requested overrides applied.
propsgetterList<Object?> get propsEquatable props used for value equality: appId, appKey, userId, userName, baseUrl, tokenBaseUrl, theme, strings, enableMinimize, enableCallKit, enablePush. Note minimizeConfig is intentionally excluded.
UTDCallMinimizeConfigclassconst UTDCallMinimizeConfig({VoidCallback? onClose, UTDCallMiniOverlayBuilder? overlayBuilder, double overlayWidth = 110, double overlayHeight = 150, double overlayBottomOffset = 120, double overlayRightOffset = 16, double borderRadius = 16, bool showEndButton = true, bool enableOSPip = false, int pipAspectWidth = 9, int pipAspectHeight = 16})Configuration for minimizing a call to a floating in-app overlay (and, optionally, an Android OS-level Picture-in-Picture window). Mirrors the audio kit's UTDMinimizeConfig, trimmed for a 1:1 call (no room cover; the overlay shows the peer + remote video when present).
پارامترها
onCloseVoidCallback?Called when the floating overlay's end button is tapped (after the call is torn down). The host typically clears any call route here.
overlayBuilderUTDCallMiniOverlayBuilder?A fully custom overlay builder. When null the kit's default tile is used.
overlayWidthdoubleپیشفرض = 110Default overlay tile width (logical px).
overlayHeightdoubleپیشفرض = 150Default overlay tile height (logical px).
overlayBottomOffsetdoubleپیشفرض = 120Initial inset of the overlay from the bottom of the screen.
overlayRightOffsetdoubleپیشفرض = 16Initial inset of the overlay from the right of the screen.
borderRadiusdoubleپیشفرض = 16Corner radius of the default overlay tile.
showEndButtonboolپیشفرض = trueWhether the default overlay shows a small end-call button.
enableOSPipboolپیشفرض = falseEnables Android OS-level Picture-in-Picture in addition to the in-app overlay. On Android 12+ (API 31+) the app auto-enters a system PiP window when backgrounded while on the call screen. iOS / Android < 31 ignore this and keep the overlay.
pipAspectWidthintپیشفرض = 9Numerator of the PiP window aspect ratio. Must satisfy Android's bounds (between 1/2.39 and 2.39/1) or PiP entry is skipped.
pipAspectHeightintپیشفرض = 16Denominator of the PiP window aspect ratio. Defaults give a portrait 9:16 phone-call window.
onClosepropertyfinal VoidCallback? onCloseCalled when the floating overlay's end button is tapped (after the call is torn down).
overlayBuilderpropertyfinal UTDCallMiniOverlayBuilder? overlayBuilderA fully custom overlay builder. When null the kit's default tile is used.
enableOSPippropertyfinal bool enableOSPipEnables Android OS-level Picture-in-Picture in addition to the in-app overlay (Android 12+/API 31+). Defaults to false (no behavior change).
UTDCallMiniOverlayBuildertypedeftypedef UTDCallMiniOverlayBuilder = Widget Function({required VoidCallback onRestore, required VoidCallback onClose})Builds a fully custom minimize overlay, overriding the kit's default. The host wires onRestore (bring the call screen back) and onClose (hang up).
پارامترها
onRestoreVoidCallbackالزامیBrings the call screen back from the overlay.
onCloseVoidCallbackالزامیHangs up / ends the call.
مقدار بازگشتی: Widget — The custom overlay widget to render.
Call state & enums
The state-machine types for a 1:1 call: the immutable UTDCallState snapshot the UI binds to, its phase/end-reason/audio-route/call-type enums, and the incoming-call invitation model.
UTDCallStateclassconst UTDCallState({UTDCallPhase phase = UTDCallPhase.idle, String? peerId, String? peerName, UTDStreamType type = UTDStreamType.audioCall, String? callId, bool isOutgoing = false, bool micMuted = false, bool cameraOn = false, bool speakerOn = false, bool remoteJoined = false, DateTime? connectedAt, UTDCallEndReason? endReason})Immutable snapshot of the current call, exposed via UTDCallController.state. Every state transition produces a new instance; it is the single value the default UI binds to. Extends Equatable for value comparison.
پارامترها
phaseUTDCallPhaseپیشفرض = UTDCallPhase.idleThe current high-level phase of the call.
peerIdString?The remote party's identity.
peerNameString?The remote party's display name, when known.
typeUTDStreamTypeپیشفرض = UTDStreamType.audioCallWhether this is a voice or video call.
callIdString?The engine call id, once assigned.
isOutgoingboolپیشفرض = falseWhether the local user is the caller (true) or the callee (false).
micMutedboolپیشفرض = falseWhether the local microphone is muted.
cameraOnboolپیشفرض = falseWhether the local camera is publishing; true from connect on a video call and toggled live by toggleCamera.
speakerOnboolپیشفرض = falseWhether audio is routed to the loudspeaker.
remoteJoinedboolپیشفرض = falseWhether the remote party has joined the media room.
connectedAtDateTime?When the call became active (the timer's epoch); null until the call connects.
endReasonUTDCallEndReason?Why the call ended, set on a terminal ended state.
phasefieldfinal UTDCallPhase phaseThe current high-level phase of the call.
typefieldfinal UTDStreamType typeWhether this is a voice or video call.
endReasonfieldfinal UTDCallEndReason? endReasonWhy the call ended, on a terminal UTDCallPhase.ended state; otherwise null.
connectedAtfieldfinal DateTime? connectedAtWhen the call became active (the duration timer's epoch); null until the call connects.
peerLabelgetterString? get peerLabelThe best label for the peer: peerName when non-empty, else peerId, else null.
مقدار بازگشتی: String? — Display name, falling back to identity, or null.
isInCallgetterbool get isInCallWhether a call is in any non-idle, non-ended phase.
مقدار بازگشتی: bool — True when phase is neither idle nor ended.
isVideogetterbool get isVideoWhether this is a video call (the call type carries video).
مقدار بازگشتی: bool — True when type.hasVideo is true.
durationgetterDuration get durationElapsed call duration since connectedAt, or Duration.zero before connect.
مقدار بازگشتی: Duration — Time elapsed since the call connected.
copyWithmethodUTDCallState copyWith({UTDCallPhase? phase, String? peerId, String? peerName, UTDStreamType? type, String? callId, bool? isOutgoing, bool? micMuted, bool? cameraOn, bool? speakerOn, bool? remoteJoined, DateTime? connectedAt, UTDCallEndReason? endReason})Returns a new UTDCallState with the given fields overridden and the rest copied from this instance.
پارامترها
phaseUTDCallPhase?New phase, or keep current.
peerIdString?New peer identity, or keep current.
peerNameString?New peer display name, or keep current.
typeUTDStreamType?New call type, or keep current.
callIdString?New engine call id, or keep current.
isOutgoingbool?New caller/callee flag, or keep current.
micMutedbool?New mic-muted flag, or keep current.
cameraOnbool?New camera-on flag, or keep current.
speakerOnbool?New speaker-on flag, or keep current.
remoteJoinedbool?New remote-joined flag, or keep current.
connectedAtDateTime?New connected timestamp, or keep current.
endReasonUTDCallEndReason?New end reason, or keep current.
مقدار بازگشتی: UTDCallState — A new snapshot with the overrides applied.
UTDCallPhaseenumThe high-level phase of a 1:1 call, driving which default screen shows. Values: idle (no call in progress), outgoing (we created the call and are ringing the callee), incoming (callee side, before accept/decline), connecting (joining the media room post-accept, before the room is live), active (both parties are in the media room), reconnecting (the media transport dropped and is auto-reconnecting), ended (terminal state; UTDCallState.endReason says why).
UTDCallEndReasonenumWhy a call ended, surfaced on a terminal UTDCallState. Values: localHangup (the local user hung up), remoteHangup (the remote party hung up / left), rejected (the callee declined), busy (the callee was on another call), missed (the callee never answered in the ring window), cancelled (the local user cancelled an outgoing call before it connected), failed (reconnection failed or a server force-exit ended the call).
UTDAudioRouteenumThe audio output destination for a call. Values: earpiece (the phone's in-ear receiver, the default for a voice call held to the ear), speaker (the loudspeaker), bluetooth (a connected Bluetooth headset).
UTDStreamTypeenumThe 1:1 call product types the signalling plane serves, mirroring the engine taxonomy. The call type passed to startCall (defaults to audioCall). Values: audioCall (wire 'audio_call' — 1:1 audio call), videoCall (wire 'video_call' — 1:1 audio + video call). Each value carries a `wire` string the engine expects, plus getters `isCall` (true for audioCall or videoCall) and `hasVideo` (true for videoCall).
wirefieldfinal String wireThe exact string the engine expects on the wire for this stream type, e.g. 'audio_call'.
isCallgetterbool get isCallWhether this stream type is a 1:1 call type (audioCall or videoCall).
مقدار بازگشتی: bool — True for audioCall or videoCall.
hasVideogetterbool get hasVideoWhether this stream type carries video (videoCall).
مقدار بازگشتی: bool — True for videoCall.
UTDCallInvitationclassconst UTDCallInvitation({required String callId, required String callerIdentity, String? callerName, UTDStreamType type = UTDStreamType.audioCall, Map<String, dynamic>? metadata})An incoming 1:1 call delivered over the signalling WebSocket (`call.invitation`). The callee answers with UTDSignalClient.acceptCall (or rejects/marks busy).
پارامترها
callIdStringالزامیThe call id to answer.
callerIdentityStringالزامیThe caller's identity.
callerNameString?The caller's display name, when provided.
typeUTDStreamTypeپیشفرض = UTDStreamType.audioCallWhether the call is audio or video.
metadataMap<String, dynamic>?Arbitrary caller-supplied metadata, when any.
UTDCallInvitation.fromDataconstructorfactory UTDCallInvitation.fromData(Map<String, dynamic> d)Builds a UTDCallInvitation from a decoded WebSocket data map (keys: call_id, caller_identity, caller_name, type, metadata); maps type 'video' to videoCall, otherwise audioCall.
پارامترها
dMap<String, dynamic>الزامیThe decoded `call.invitation` payload.
UTDCallSignalKindenumA non-invitation call signal pushed over the WebSocket after an invite. Values: ringing, accepted, rejected, busy, ended (mapping the `call.ringing` / `call.accepted` / `call.rejected` / `call.busy` / `call.ended` frame types).
UTDCallUpdateclassconst UTDCallUpdate({required UTDCallSignalKind kind, required String callId, Map<String, dynamic> data = const {}})A progress update on an in-flight call other than the initial invitation, carrying the signal kind, affected call id, and raw push payload.
پارامترها
kindUTDCallSignalKindالزامیWhat happened (ringing/accepted/rejected/busy/ended).
callIdStringالزامیThe affected call id.
dataMap<String, dynamic>پیشفرض = const {}The raw push payload, for any extra fields.
UTDCallUpdate.fromFrameconstructorfactory UTDCallUpdate.fromFrame(UTDCallSignalKind kind, Map<String, dynamic> data)Builds a UTDCallUpdate from a parsed signal kind and the raw frame data, extracting call_id from the data map.
پارامترها
kindUTDCallSignalKindالزامیThe parsed call signal kind.
dataMap<String, dynamic>الزامیThe raw frame payload (must contain call_id).
utdCallSignalKindFromTypemethodUTDCallSignalKind? utdCallSignalKindFromType(String? frameType)Top-level helper that maps a `call.*` push frame type string to a UTDCallSignalKind, or null for `call.invitation` (handled separately) or unknown frame types.
پارامترها
frameTypeString?The push frame `type` value, e.g. 'call.ringing'.
مقدار بازگشتی: UTDCallSignalKind? — The matching signal kind, or null if not a recognized call.* update frame.
Sessions & client
The lower-level session/client layer: UTDCallsClient is the transport facade (REST + signalling, mint-on-connect, push dispatch) that mints UTDCallSession instances, while UTDSession/UTDCallSession drive a single 1:1 call's lifecycle over a headless LiveKit room.
UTDCallsClientclassUTDCallsClient(UTDCallsConfig config)A facade owning the calls-kit transport: a UTDApiClient + UTDApi (REST), a UTDSignalClient (presence + incoming-call WebSocket), and the per-call UTDCallSessions. On init it performs the no-backend mint (POST /api/v1/auth/session with X-App-Id/X-App-Key) to obtain a per-user user_token (applied as the engine bearer) and ws_url, which doubles as the signalling WS credential. Re-exposes the signal client's incomingCalls/callUpdates/forceExit streams and drives the optional push dispatcher.
پارامترها
configUTDCallsConfigالزامیThe kit configuration: mint credentials (appId/appKey), local user identity (userId/userName), engine hosts, and push/UI flags. Used to build the internal UTDApiClient and signal client.
configfieldfinal UTDCallsConfig configThe kit configuration passed to the constructor (credentials, hosts, identity, flags).
مقدار بازگشتی: UTDCallsConfig
apigetterUTDApi get apiThe REST facade used for mints and call actions (createCall/acceptCall/endCall, push token register, etc.).
مقدار بازگشتی: UTDApi
signalgetterUTDSignalClient get signalThe realtime signalling client (presence + incoming-call WebSocket).
مقدار بازگشتی: UTDSignalClient
incomingCallsgetterStream<UTDCallInvitation> get incomingCallsStream of incoming 1:1 calls (the callee side), forwarded from the signal client.
مقدار بازگشتی: Stream<UTDCallInvitation>
callUpdatesgetterStream<UTDCallUpdate> get callUpdatesStream of progress on in-flight calls (ringing/accepted/rejected/busy/ended), forwarded from the signal client.
مقدار بازگشتی: Stream<UTDCallUpdate>
forceExitgetterStream<UTDForceExitReason> get forceExitStream of server force-close events (single-active-session takeover, WS close code 4003).
مقدار بازگشتی: Stream<UTDForceExitReason>
signalStategetterValueListenable<UTDConnectionState> get signalStateThe signalling connection state as a ValueListenable.
مقدار بازگشتی: ValueListenable<UTDConnectionState>
isInitializedgetterbool get isInitializedWhether init() has completed and the bearer is applied.
مقدار بازگشتی: bool
initmethodasyncFuture<void> init()Mint the bearer (no-backend) and connect the signalling WebSocket; if config.enablePush is true it also starts push-token collection/registration. Idempotent: a second call is a no-op once initialized (or after dispose). Throws UTDStreamException if the mint or signal connect fails. The mint runs inside the signal client's credentials provider, so connecting both opens the socket and applies the freshly-minted bearer.
مقدار بازگشتی: Future<void>
createSessionmethodUTDCallSession createSession(UTDStreamType type)Create a new UTDCallSession for the given call type, wired to the internal REST API. The caller drives it via start()/accept()/end(); the controller wires it to the UI.
پارامترها
typeUTDStreamTypeالزامیThe call product type (audioCall or videoCall) the session will serve.
مقدار بازگشتی: UTDCallSession
unregisterPushmethodasyncFuture<void> unregisterPush()Unregister this device's push token with the engine (e.g. on sign-out). Best-effort: a UTDStreamException is swallowed so sign-out proceeds regardless.
مقدار بازگشتی: Future<void>
disposemethodasyncFuture<void> dispose()Dispose the transport (push dispatcher, signal client, and API client). Idempotent; the object must not be used afterwards.
مقدار بازگشتی: Future<void>
UTDCallSessionclassUTDCallSession({required UTDApi api, required UTDStreamType type})A 1:1 call session (audioCall or videoCall) backed by a headless LiveKit room capped at 2 participants by the engine. Both parties publish. The caller start()s a call; the callee accept()s an incoming one (the call_id arrives out-of-band via push or the engine presence socket). Extends UTDSession. Asserts the given type is a call type.
پارامترها
apiUTDApiالزامیThe REST facade used for call lifecycle actions (create/accept/ringing/reject/busy/end).
typeUTDStreamTypeالزامیThe call type; must be a call type (audioCall or videoCall) or the constructor assertion fails.
statusfieldfinal ValueNotifier<UTDCallStatus?> statusThe current call status as a ValueNotifier, or null before start()/accept(). Changes are forwarded to the registered handler's onCallStateChanged.
مقدار بازگشتی: ValueNotifier<UTDCallStatus?>
callIdfieldfinal ValueNotifier<String?> callIdThe current call id as a ValueNotifier, or null before start()/accept().
مقدار بازگشتی: ValueNotifier<String?>
startmethodasyncFuture<UTDCall> start({required String calleeIdentity, String? calleeName, Map<String, dynamic>? metadata})Caller side: create the call, ring the callee, set callId/status, and (if the engine returned join credentials) connect to the media room and publish. Returns the engine UTDCall.
پارامترها
calleeIdentityStringالزامیThe engine identity of the user being called.
calleeNameString?Optional display name for the callee.
metadataMap<String, dynamic>?Optional metadata attached to the created call.
مقدار بازگشتی: Future<UTDCall> — The created engine call.
acceptmethodasyncFuture<UTDCall> accept(String id)Callee side: accept an incoming call by id, set callId/status to the engine's actual returned status (which may resolve to ended/busy if the caller bailed first), and if connectable join the media room and publish. Returns the engine UTDCall.
پارامترها
idStringالزامیThe incoming call id received out-of-band (push or presence socket).
مقدار بازگشتی: Future<UTDCall> — The accepted engine call.
ringingmethodasyncFuture<void> ringing(String id)Notify the engine that the callee device is ringing for the given call id; updates status from the response.
پارامترها
idStringالزامیThe call id to mark as ringing.
مقدار بازگشتی: Future<void>
rejectmethodasyncFuture<void> reject(String id)Reject the incoming call with the given id; updates status from the response.
پارامترها
idStringالزامیThe call id to reject.
مقدار بازگشتی: Future<void>
busymethodasyncFuture<void> busy(String id)Mark the given call id as busy (callee on another call); updates status from the response.
پارامترها
idStringالزامیThe call id to mark busy.
مقدار بازگشتی: Future<void>
endmethodasyncFuture<void> end()Hang up the active call: end it server-side (swallowing UTDStreamException when the call already reached a terminal state, in which case status is set to ended locally) and disconnect the media room. Local teardown proceeds even if the server call fails with a UTDStreamException.
مقدار بازگشتی: Future<void>
UTDSessionclassUTDSession({required UTDApi api, required UTDStreamType type, UTDRoom? room})Abstract shared base for every session type. Owns a UTDRoom and re-exposes its headless state two ways: per-field ValueListenables plus a raw event stream (reactive), and a single assignable UTDStreamEventHandler (imperative). Concrete sessions (e.g. UTDCallSession) add the per-type control surface and feed the handler with typed events. Constructor is for subclasses.
پارامترها
apiUTDApiالزامیThe REST facade (protected; used by subclasses for lifecycle actions).
typeUTDStreamTypeالزامیThe product type this session serves.
roomUTDRoom?Optional pre-built headless room; defaults to a UTDRoom with adaptiveStream and dynacast enabled.
typefieldfinal UTDStreamType typeThe product type this session serves.
مقدار بازگشتی: UTDStreamType
roomfieldfinal UTDRoom roomThe headless LiveKit room wrapper backing this session.
مقدار بازگشتی: UTDRoom
setEventHandlermethodvoid setEventHandler(UTDStreamEventHandler handler)Register a single UTDStreamEventHandler for everything this session emits, replacing any previous handler. The reactive listenables and raw events stream remain available alongside it.
پارامترها
handlerUTDStreamEventHandlerالزامیThe handler whose assigned callbacks receive typed session events.
clearEventHandlermethodvoid clearEventHandler()Remove the registered event handler, if any.
connectionStategetterValueListenable<UTDConnectionState> get connectionStateThe connection lifecycle state (mirrors the underlying room).
مقدار بازگشتی: ValueListenable<UTDConnectionState>
connectedgetterValueListenable<bool> get connectedWhether the room is connected (boolean mirror of connectionState).
مقدار بازگشتی: ValueListenable<bool>
remoteParticipantsgetterValueListenable<List<RemoteParticipant>> get remoteParticipantsThe current remote participants in the room.
مقدار بازگشتی: ValueListenable<List<RemoteParticipant>>
localParticipantgetterLocalParticipant? get localParticipantThe local participant, or null before connecting.
مقدار بازگشتی: LocalParticipant?
eventsgetterStream<RoomEvent> get eventsThe raw LiveKit RoomEvent firehose.
مقدار بازگشتی: Stream<RoomEvent>
forceExitgetterStream<UTDForceExitReason> get forceExitFires once when the session is forcibly ended (ban / takeover / kick / reconnect timeout).
مقدار بازگشتی: Stream<UTDForceExitReason>
setMicrophonemethodasyncFuture<void> setMicrophone(bool enabled)Toggle the local mic publish (works once the server has granted publish).
پارامترها
enabledboolالزامیWhether the microphone should publish.
مقدار بازگشتی: Future<void>
setSpeakerOnmethodasyncFuture<void> setSpeakerOn(bool on)Route audio to the loudspeaker (true) or earpiece (false).
پارامترها
onboolالزامیTrue for loudspeaker, false for earpiece.
مقدار بازگشتی: Future<void>
switchCameramethodasyncFuture<void> switchCamera()Switch between the front and back camera.
مقدار بازگشتی: Future<void>
leavemethodasyncFuture<void> leave()Leave the media room but keep the session object reusable (disconnects without disposing).
مقدار بازگشتی: Future<void>
disposemethodasyncFuture<void> dispose()Tear down the session and its LiveKit room: detaches listeners, cancels subscriptions, and disposes the room. Must be called via super by subclasses.
مقدار بازگشتی: Future<void>
UTDStreamEventHandlerclassconst UTDStreamEventHandler({void Function(UTDConnectionState state)? onConnectionStateChanged, void Function(UTDForceExitReason reason)? onForceExit, void Function(UTDStreamException error)? onError, void Function(RemoteParticipant participant)? onUserJoined, void Function(RemoteParticipant participant)? onUserLeft, void Function(UTDCallStatus status)? onCallStateChanged, void Function(Map<String, dynamic> data)? onData})A single, assignable place to register for everything a session emits — the imperative counterpart to the per-field ValueListenables, modelled on assignable callbacks but per-session (no global statics, so concurrent sessions stay independent). Assign the fields you care about and hand it to session.setEventHandler; every field is optional. Trimmed for the calls kit to only the call-relevant callbacks.
پارامترها
onConnectionStateChangedvoid Function(UTDConnectionState state)?Called when the connection lifecycle changes.
onForceExitvoid Function(UTDForceExitReason reason)?Called when the session is forcibly ended (ban / takeover / kick / reconnect timeout).
onErrorvoid Function(UTDStreamException error)?Called when a recoverable error occurs outside an awaited call (e.g. background re-sync or audio-routing failure).
onUserJoinedvoid Function(RemoteParticipant participant)?Called when the remote party joins the call.
onUserLeftvoid Function(RemoteParticipant participant)?Called when the remote party leaves the call.
onCallStateChangedvoid Function(UTDCallStatus status)?Called when a 1:1 call's status changes.
onDatavoid Function(Map<String, dynamic> data)?Called for any decoded data-channel message not consumed by a typed callback above.
Push & native call UI
Push and OS-native call UI: token collection, background/killed-state CallKit push presentation and cold-start resume (UTDPushDispatcher, UTDCallPush), plus the native CallKit/ConnectionService accept/decline bridge (UTDCallKitBridge).
UTDPushDispatcherclassUTDPushDispatcher({required void Function({String? fcmToken, String? voipToken, required UTDPushPlatform platform}) onTokens, String appName = 'UTD Calls'})Owns the push transport for the calls kit: collects device push tokens (iOS PushKit VoIP via FlutterCallkitIncoming.getDevicePushTokenVoIP and/or the FCM token via FirebaseMessaging), reports them through onTokens for engine registration, and routes foreground {type:'call'} FCM messages into CallKit. iOS VoIP pushes are delivered to CallKit natively, so this dispatcher focuses on token collection on both platforms and the Android FCM data-message to CallKit path. The host must call Firebase.initializeApp() before start().
پارامترها
onTokensvoid Function({String? fcmToken, String? voipToken, required UTDPushPlatform platform})الزامیCalled whenever the set of available push tokens changes (initial collect and every refresh). Either token field may be null when the platform does not provide it. The host registers them with the engine via UTDPushTokenApi.
appNameStringپیشفرض = 'UTD Calls'App name shown on the CallKit screen for FCM-driven incoming calls.
startmethodasyncFuture<void> start()Starts the dispatcher: registers the FCM background handler, requests iOS notification permission, collects the initial tokens, wires foreground call messages, and subscribes to FCM and iOS VoIP token refreshes. Idempotent (no-op if already started or disposed). The host MUST have called Firebase.initializeApp() beforehand.
مقدار بازگشتی: Future<void> — Completes once the dispatcher is wired and the initial tokens have been collected and reported.
coldStartAcceptedCallmethodasyncstatic Future<UTDCallPush?> coldStartAcceptedCall()Static. Reads the kit call_id of the CallKit call the app was cold-launched into, if any (e.g. the user accepted a VoIP/FCM call from a killed state). Prefers an already-accepted call, falling back to the most recent active call. Returns null when there is no pending native call or no usable call_id. The controller uses this on init to resume the accepted call.
مقدار بازگشتی: Future<UTDCallPush?> — The parsed push for the cold-started accepted call, or null when none exists.
disposemethodasyncFuture<void> dispose()Cancels the foreground-message, FCM token-refresh, and VoIP token-refresh subscriptions and marks the dispatcher disposed. Idempotent.
مقدار بازگشتی: Future<void> — Completes once all subscriptions are cancelled.
appNamefieldfinal String appNameApp name shown on the CallKit screen for FCM-driven incoming calls.
onTokensfieldfinal void Function({String? fcmToken, String? voipToken, required UTDPushPlatform platform}) onTokensCallback invoked with the latest push tokens (fcmToken / voipToken, either nullable) and the current UTDPushPlatform whenever tokens are collected or refreshed.
UTDCallPushclassconst UTDCallPush({required String callId, required String callerIdentity, String? callerName, UTDStreamType type = UTDStreamType.audioCall})Immutable data payload the engine sends for a background call push, normalised away from the raw FCM map. Mirrors the engine contract {type:'call', call_id, caller_identity, caller_name, call_type:'voice'|'video'}.
پارامترها
callIdStringالزامیThe kit call_id to accept/join.
callerIdentityStringالزامیThe caller's engine identity.
callerNameString?The caller's display name, when the engine provided one.
typeUTDStreamTypeپیشفرض = UTDStreamType.audioCallWhether the call is audio (voice) or video. One of UTDStreamType.audioCall or UTDStreamType.videoCall.
tryParsemethodstatic UTDCallPush? tryParse(Map<String, dynamic> data)Static. Parses the engine's FCM data map into a UTDCallPush. Returns null when the map is not a type:'call' push or lacks a usable call_id. Maps call_type=='video' to UTDStreamType.videoCall, otherwise UTDStreamType.audioCall.
پارامترها
dataMap<String, dynamic>الزامیThe raw FCM data map from the engine push.
مقدار بازگشتی: UTDCallPush? — The parsed push, or null when the map is not a usable call push.
callIdfieldfinal String callIdThe kit call_id to accept/join.
callerIdentityfieldfinal String callerIdentityThe caller's engine identity.
callerNamefieldfinal String? callerNameThe caller's display name, when the engine provided one; otherwise null.
typefieldfinal UTDStreamType typeWhether the call is audio or video (UTDStreamType.audioCall or UTDStreamType.videoCall).
showCallkitForPushmethodasyncFuture<void> showCallkitForPush(UTDCallPush push)Top-level function. Presents the OS-native incoming-call UI (CallKit/ConnectionService) for a background/killed-state call push. Used by both the FCM background isolate and the foreground handler, so it must not touch the controller or app state — it only renders CallKit. The call_id (and call type) is stored in CallKitParams.extra so the accept event can resolve it back. A fresh UUID is generated for the CallKit call id.
پارامترها
pushUTDCallPushالزامیThe parsed call push to display the native incoming-call UI for.
مقدار بازگشتی: Future<void> — Completes once the native incoming-call UI has been shown.
utdFirebaseBackgroundHandlermethodasyncFuture<void> utdFirebaseBackgroundHandler(RemoteMessage message)Top-level Android FCM background message handler, annotated @pragma('vm:entry-point') so it is a valid entry point for the background FlutterEngine. On a {type:'call'} data message it parses the payload and shows the full-screen CallKit incoming UI; non-call messages are ignored. The user's accept later reaches the app (waking it from killed) and is handled by UTDPushDispatcher in the main isolate.
پارامترها
messageRemoteMessageالزامیThe incoming FCM background message.
مقدار بازگشتی: Future<void> — Completes after the native UI is shown, or immediately when the message is not a call push.
UTDCallKitBridgeclassUTDCallKitBridge({String appName = 'UTD Calls'})Wraps FlutterCallkitIncoming to present the OS-native incoming-call UI (CallKit on iOS, ConnectionService on Android) for an in-app UTDCallInvitation and to bridge the user's choice back to the controller. Owns the call_id↔UUID mapping (a UUID is generated the first time a call_id is shown and reused thereafter) and translates the plugin's sealed CallEvent stream into a normalised events stream of UTDCallKitEvent. Background/killed pushes shown by UTDPushDispatcher carry the call_id in CallKitParams.extra and are resolved from there.
پارامترها
appNameStringپیشفرض = 'UTD Calls'App name shown on the native call screen.
eventsgetterStream<UTDCallKitEvent> get eventsBroadcast stream of normalised native-UI actions (accept / decline / ended / timeout), each carrying the kit call_id. The controller listens here to drive the call.
مقدار بازگشتی: Stream<UTDCallKitEvent> — The normalised native call-UI event stream.
startmethodvoid start()Begins bridging FlutterCallkitIncoming.onEvent into the events stream. Idempotent (no-op if already started or disposed).
showIncomingmethodasyncFuture<void> showIncoming(UTDCallInvitation invitation)Shows the native incoming-call UI for the given invitation. A UUID is generated for the invitation's call_id (or reused if already shown) so accept/decline events map back to the same call. The call_id is also stored in CallKitParams.extra.
پارامترها
invitationUTDCallInvitationالزامیThe in-app call invitation (delivered over the signal WebSocket) to present native UI for.
مقدار بازگشتی: Future<void> — Completes once the native incoming-call UI has been shown.
setConnectedmethodasyncFuture<void> setConnected(String callId)Marks the call connected on the native UI (starts its in-call timer). Call when the media room connects or the remote joins. No-op when the call_id has no registered UUID.
پارامترها
callIdStringالزامیThe kit call_id to mark connected.
مقدار بازگشتی: Future<void> — Completes once the native UI has been updated.
endCallmethodasyncFuture<void> endCall(String callId)Dismisses the native UI for one call (after a local/remote hang-up) and removes its call_id↔UUID mapping. No-op when the call_id is unknown.
پارامترها
callIdStringالزامیThe kit call_id whose native UI should be dismissed.
مقدار بازگشتی: Future<void> — Completes once the native call UI has been dismissed.
endAllCallsmethodasyncFuture<void> endAllCalls()Dismisses every native call UI and clears all call_id↔UUID mappings (teardown / takeover).
مقدار بازگشتی: Future<void> — Completes once all native call UIs have been dismissed.
disposemethodasyncFuture<void> dispose()Cancels the plugin subscription, closes the events stream, and clears the call_id↔UUID mappings. The bridge must not be used afterwards. Idempotent.
مقدار بازگشتی: Future<void> — Completes once the bridge has been torn down.
UTDCallKitEventclassconst UTDCallKitEvent({required UTDCallKitAction action, required String callId})Immutable native call-UI action paired with the kit call_id it refers to. Emitted on UTDCallKitBridge.events.
پارامترها
actionUTDCallKitActionالزامیWhat happened on the native UI.
callIdStringالزامیThe kit call_id the action refers to (resolved from the call's UUID), or empty when the UUID could not be mapped back (already-ended call).
actionfieldfinal UTDCallKitAction actionWhat happened on the native UI (a UTDCallKitAction value).
callIdfieldfinal String callIdThe kit call_id the action refers to, or empty when it could not be mapped back to a known call.
UTDCallKitActionenumWhat the user (or system) did on the native call UI, normalised away from the plugin's sealed CallEvent hierarchy. Values: accept (tapped Accept), decline (tapped Decline), ended (call ended/hung up from native UI), timeout (ring window elapsed with no answer / missed).
آمادهاید با UTD بسازید؟
حساب خود را بسازید، کیف پول اصلیتان را شارژ کنید و سرویسهایی را که نیاز دارید روشن کنید.