< Flutter UIKit />
UTD Calls Kit
نیٹیو کال UI اور پُش کے ساتھ ڈراپ-اِن 1:1 آڈیو اور ویڈیو کالز۔
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
مکمل UI
CallKit
+ VoIP پُش
< utd_calls_kit />
اہم خصوصیات
LiveKit اور UTD Stream Engine سے چلنے والا، 1:1 آڈیو اور ویڈیو کالنگ کے لیے ایک پروڈکشن-ریڈی Flutter پیکیج۔ OS-نیٹیو کال UI (CallKit/ConnectionService) کے ساتھ ڈراپ-اِن آؤٹ گوئنگ، اِن کمنگ اور اِن-کال اسکرینز، VoIP/FCM سے بند ایپ کو جگانا، اسپیکر/ایئرپیس/Bluetooth روٹنگ، proximity blanking، minimize اور Android Picture-in-Picture — اور کسی بیک اینڈ ٹوکن سرور کی ضرورت کے بغیر۔
ڈراپ-اِن کال UI: آؤٹ گوئنگ، اِن کمنگ اور اِن-کال اسکرینز — کوئی اضافی کوڈ نہیں
1:1 آڈیو اور ویڈیو، دورانِ کال لائیو آڈیو↔ویڈیو اپ گریڈ کے ساتھ
OS-نیٹیو اِن کمنگ-کال UI: CallKit (iOS) اور ConnectionService (Android)
VoIP/FCM سے بند ایپ کو جگانا، cold-start قبول اور resume کے ساتھ
میڈیا کنٹرولز: مائیک، کیمرہ، اسپیکر/ایئرپیس/Bluetooth روٹنگ
کان سے لگائی گئی صوتی کالز پر proximity blanking
فلوٹنگ اوورلے اور Android OS Picture-in-Picture میں minimize
تھیم کسٹمائزیشن اور بلٹ-اِن i18n (EN/AR)
کوئی بیک اینڈ ٹوکن سرور نہیں — appKey پر مبنی ٹوکن minting
< 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 کے ساتھ تعمیر کے لیے تیار ہیں؟
اپنا اکاؤنٹ بنائیں، اپنے ماسٹر والٹ کو فنڈ کریں، اور جن سروسز کی ضرورت ہے انہیں آن کریں۔