العودة إلى المطوّرين

< حزمة واجهات Flutter />

UTD Calls Kit

مكالمات صوت وفيديو فردية جاهزة بواجهة مكالمات أصلية وإشعارات.

الإصدار 0.9.1على pub.dev
iOS 12+Android 21+
calls_kit.dart
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

+ إشعار VoIP

< utd_calls_kit />

أبرز المزايا

حزمة Flutter جاهزة للإنتاج للمكالمات الصوتية ومكالمات الفيديو الفردية، مدعومة بـ LiveKit ومحرّك UTD Stream. شاشات جاهزة للمكالمات الصادرة والواردة وأثناء المكالمة بواجهة مكالمات أصلية للنظام (CallKit/ConnectionService)، وإيقاظ من حالة الإغلاق عبر VoIP/FCM، وتوجيه السمّاعة/سمّاعة الأذن/البلوتوث، وتعتيم بالقرب، وتصغير وصورة-داخل-صورة على نظام أندرويد — دون الحاجة إلى خادم توكنات في الخلفية.

واجهة مكالمات جاهزة: شاشات صادرة وواردة وأثناء المكالمة — دون أي كود إضافي

صوت وفيديو فردي مع ترقية مباشرة من صوت↔فيديو أثناء المكالمة

واجهة مكالمات واردة أصلية للنظام: CallKit (iOS) وConnectionService (Android)

إيقاظ من حالة الإغلاق عبر VoIP/FCM مع قبول واستئناف من البدء البارد

تحكم في الوسائط: ميكروفون، كاميرا، توجيه السمّاعة/سمّاعة الأذن/البلوتوث

تعتيم بالقرب في المكالمات الصوتية الملاصقة للأذن

تصغير إلى نافذة عائمة وصورة-داخل-صورة على نظام أندرويد

تخصيص السمات ودعم لغوي مدمج (الإنجليزية/العربية)

دون خادم توكنات خلفي — إصدار توكنات قائم على appKey

< utd_calls_kit />

ابدأ الآن

1

التثبيت

Terminal
flutter pub add utd_calls_kit
2

عرض على pub.dev

مكالمات صوت وفيديو فردية جاهزة بواجهة مكالمات أصلية وإشعارات.

< 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.

UTDCallViewwidget
const 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?القيمة الافتراضية = null

    An externally-owned controller to adopt. When null, UTDCallView creates and owns one (and disposes it on unmount).

  • onControllerReadyvoid Function(UTDCallController controller)?القيمة الافتراضية = null

    Called once the controller is built (and init() started when autoInit), so the host can drive calls or wire callbacks.

  • autoInitboolالقيمة الافتراضية = true

    Whether to call UTDCallController.init automatically on mount.

  • idleBuilderWidgetBuilder?القيمة الافتراضية = null

    What to render when there is no call in progress (idle / ended). Defaults to an empty SizedBox so the host controls navigation.

configfield
final UTDCallsConfig config

Immutable configuration (credentials, hosts, identity, theme, strings).

controllerfield
final UTDCallController? controller

An externally-owned controller to adopt. When null, UTDCallView creates and owns one (and disposes it on unmount).

onControllerReadyfield
final void Function(UTDCallController controller)? onControllerReady

Called once the controller is built (and init() started when autoInit).

autoInitfield
final bool autoInit

Whether to call UTDCallController.init automatically on mount.

idleBuilderfield
final WidgetBuilder? idleBuilder

What to render when there is no call in progress (idle / ended). Defaults to an empty SizedBox so the host controls navigation.

UTDCallView.createStatemethod
State<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.

UTDOutgoingCallScreenwidget
const 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.statefield
final UTDCallState state

The current immutable call snapshot driving the displayed peer label and ringing/connecting status.

UTDOutgoingCallScreen.buildmethod
Widget build(BuildContext context)

Builds the outgoing-call UI: avatar, peer name, ringing/connecting status text, and a cancel control wired to controller.end.

القيمة المُرجَعة: WidgetThe rendered outgoing-call screen.

UTDIncomingCallScreenwidget
const 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.statefield
final UTDCallState state

The current immutable call snapshot driving the caller label and call-type subtitle.

UTDIncomingCallScreen.buildmethod
Widget 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.

القيمة المُرجَعة: WidgetThe rendered incoming-call screen.

UTDInCallScreenwidget
const 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.statefield
final UTDCallState state

The current immutable call snapshot driving the timer, audio/video stage and reconnecting banner.

UTDInCallScreen.createStatemethod
State<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.

UTDCallPhaseenum

The 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.

UTDCallControllerclass
UTDCallController(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.

configfield
final UTDCallsConfig config

The kit configuration passed to the constructor (final UTDCallsConfig).

activeControllergetter
static UTDCallController? get activeController

Static getter returning the controller that currently owns an active/ringing call, or null when none is active.

القيمة المُرجَعة: UTDCallController?The currently active controller, or null.

hasActiveCallgetter
static bool get hasActiveCall

Static getter for whether any call is currently in progress (true when the active controller's state.isInCall is true).

القيمة المُرجَعة: boolTrue if a call is in progress.

mediafield
final UTDCallMediaController media

Thin mic/camera/speaker passthrough sub-controller, rebound to each call's room (final UTDCallMediaController).

audioRoutefield
final UTDAudioRouteController audioRoute

Speaker/earpiece/bluetooth output routing sub-controller, rebound to each call's room (final UTDAudioRouteController).

proximityfield
final UTDProximityController proximity

Proximity-based screen blanking sub-controller for an earpiece voice call (final UTDProximityController).

minimizefield
late final UTDCallMinimizeController minimize

In-app minimize (floating overlay) orchestration sub-controller; drives enableMinimize (late final UTDCallMinimizeController, created with this controller).

pipfield
late final UTDCallPipController pip

Android OS-level Picture-in-Picture orchestration sub-controller (no-op off Android; late final UTDCallPipController, created with this controller).

callStatefield
final ValueNotifier<UTDCallState> callState

The current call snapshot as a reactive ValueNotifier; also mirrored to listeners via notifyListeners (final ValueNotifier<UTDCallState>).

pendingInvitationfield
final ValueNotifier<UTDCallInvitation?> pendingInvitation

Incoming 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?>).

stategetter
UTDCallState get state

The current call snapshot, a convenience getter over callState.value.

القيمة المُرجَعة: UTDCallStateThe current call state snapshot.

onIncomingCallfield
void Function(UTDCallInvitation invitation)? onIncomingCall

Callback invoked when an incoming call arrives (callee side) while no call is active. The host typically navigates to the incoming-call screen here.

onCallEndedfield
void Function(UTDCallState finalState)? onCallEnded

Callback invoked once when the call reaches a terminal state. The host typically pops the call screen here.

initmethodasync
Future<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.

startCallmethodasync
Future<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.audioCall

    The 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.

acceptIncomingmethodasync
Future<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.

rejectmethodasync
Future<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.

endmethodasync
Future<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.

toggleMicmethodasync
Future<void> toggleMic()

Toggle the local microphone (delegates to media.toggleMicrophone).

القيمة المُرجَعة: Future<void>Completes once the mic state is toggled.

toggleCameramethodasync
Future<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.

flipCameramethodasync
Future<void> flipCamera()

Switch between the front and back camera, video calls only (delegates to media.flipCamera).

القيمة المُرجَعة: Future<void>Completes once the camera is flipped.

toggleSpeakermethodasync
Future<void> toggleSpeaker()

Toggle the loudspeaker (delegates to media.toggleSpeaker).

القيمة المُرجَعة: Future<void>Completes once the speaker state is toggled.

cycleAudioRoutemethodasync
Future<void> cycleAudioRoute()

Cycle the audio output route earpiece → speaker → bluetooth → earpiece (delegates to audioRoute.cycle).

القيمة المُرجَعة: Future<void>Completes once the route is cycled.

setAudioRoutemethodasync
Future<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.

unregisterPushmethodasync
Future<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.

disposemethod
void 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.

UTDCallMediaControllerclass
UTDCallMediaController()

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).

isMicEnabledfield
final ValueNotifier<bool> isMicEnabled

Whether the local mic is currently publishing (mirrors the room). Starts false.

isCameraEnabledfield
final ValueNotifier<bool> isCameraEnabled

Whether the local camera is currently publishing (mirrors the room). Starts false.

isSpeakerOnfield
final ValueNotifier<bool> isSpeakerOn

Whether audio is routed to the loudspeaker (mirrors the room). Starts false.

roomgetter
UTDRoom? get room

The bound room, or null before the first bind(). Exposed so the UI can render local/remote video tracks via the LiveKit room.

bindmethod
void 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.

unbindmethod
void unbind()

Stop mirroring the current room (e.g. on call end) without disposing it — the session owns the room's lifecycle.

toggleMicrophonemethodasync
Future<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.

setMicrophoneEnabledmethodasync
Future<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.

toggleCameramethodasync
Future<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.

setCameraEnabledmethodasync
Future<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.

flipCameramethodasync
Future<void> flipCamera()

Switch between the front and back camera. No-op when the camera is off.

القيمة المُرجَعة: Future<void>Completes once the camera is switched.

toggleSpeakermethodasync
Future<void> toggleSpeaker()

Toggle the loudspeaker (calls setSpeakerOn with the inverse of isSpeakerOn).

القيمة المُرجَعة: Future<void>Completes once the speaker request is sent.

setSpeakerOnmethodasync
Future<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.

applyBluetoothAudioRoutingmethodasync
Future<void> applyBluetoothAudioRouting()

Apply the Android Bluetooth-routing fix; call after connect + mic publish.

القيمة المُرجَعة: Future<void>Completes once the routing fix is applied.

disposemethod
void dispose()

Unbind and dispose the mic/camera/speaker notifiers. Idempotent.

UTDAudioRouteenum
enum 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).

UTDAudioRouteControllerclass
UTDAudioRouteController()

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.

routefield
final ValueNotifier<UTDAudioRoute> route

The 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.

bindmethod
void 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.

unbindmethod
void unbind()

Stop mirroring the current room without disposing it (the session owns the room lifecycle).

setRoutemethodasync
Future<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.

cyclemethodasync
Future<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.

applyBluetoothAudioRoutingmethodasync
Future<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.

disposemethod
void dispose()

Unbind and dispose the route notifier. Idempotent.

UTDProximityControllerclass
UTDProximityController()

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.

isNearfield
final ValueNotifier<bool> isNear

Whether 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.

updatemethod
void 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.

disposemethod
void dispose()

Stop the sensor and dispose the isNear notifier. Idempotent.

UTDCallMiniOverlayStateenum
enum 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).

UTDCallMiniOverlayMachineclass
UTDCallMiniOverlayMachine instance

Process-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).

UTDCallMinimizeControllerclass
UTDCallMinimizeController(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.

isMinimizinggetter
bool get isMinimizing

Whether a call is currently minimized to the overlay (proxies the overlay machine).

stateNotifiergetter
ValueNotifier<UTDCallMiniOverlayState> get stateNotifier

The minimize-state notifier from the underlying overlay machine; bind UI to react to idle/inCall/minimizing transitions.

configgetter
UTDCallMinimizeConfig? get config

The minimize configuration set via configure(), or null if not yet configured.

datagetter
UTDCallMinimizeData? get data

The captured navigation snapshot (controller + route name + arguments), or null when no minimize is active.

configuremethod
void configure(UTDCallMinimizeConfig config)

Set the overlay/PiP configuration used when minimizing.

المعاملات

  • configUTDCallMinimizeConfigمطلوب

    The minimize/PiP configuration.

captureNavigationmethod
void 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.

startMinimizemethod
bool 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.

القيمة المُرجَعة: boolTrue if the minimize started; false if it was a no-op.

restoremethod
bool 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.

القيمة المُرجَعة: boolTrue if a restore was scheduled; false otherwise.

restoreWithNavigatormethod
bool 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.

القيمة المُرجَعة: boolTrue if a restore was scheduled; false otherwise.

closemethodasync
Future<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.

dismissmethod
void dismiss()

Dismiss the overlay without ending the call or invoking onClose. Used internally when the controller tears a call down on its own.

UTDCallMinimizeConfigclass
const 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القيمة الافتراضية = 110

    Default overlay tile width (logical px).

  • overlayHeightdoubleالقيمة الافتراضية = 150

    Default overlay tile height (logical px).

  • overlayBottomOffsetdoubleالقيمة الافتراضية = 120

    Initial inset of the overlay from the bottom of the screen.

  • overlayRightOffsetdoubleالقيمة الافتراضية = 16

    Initial inset of the overlay from the right of the screen.

  • borderRadiusdoubleالقيمة الافتراضية = 16

    Corner radius of the default overlay tile.

  • showEndButtonboolالقيمة الافتراضية = true

    Whether the default overlay shows a small end-call button.

  • enableOSPipboolالقيمة الافتراضية = false

    Enables 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القيمة الافتراضية = 9

    Numerator 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القيمة الافتراضية = 16

    Denominator of the PiP window aspect ratio; defaults to a portrait 9:16 phone-call window.

UTDCallMiniOverlayBuildertypedef
typedef 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).

UTDCallPipControllerclass
UTDCallPipController(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.

isInPipfield
final ValueNotifier<bool> isInPip

True while the app is actually shrunk into the system PiP window. Starts false.

armIfEnabledmethodasync
Future<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.

setInPipmethod
void 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.

disarmmethodasync
Future<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.

disposemethod
void 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.

UTDCallsConfigclass
const 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.defaultBaseUrl

    The engine host for privileged in-call ops (Bearer). Grey-cloud origin.

  • tokenBaseUrlStringالقيمة الافتراضية = UTDApiClient.defaultTokenBaseUrl

    The 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القيمة الافتراضية = true

    Whether 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القيمة الافتراضية = true

    Whether 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القيمة الافتراضية = true

    Whether 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.

appIdfield
final String appId

App ID for the UTD Stream Engine (e.g. "9325906999").

appKeyfield
final String appKey

The project's publishable app key (the no-backend mint credential, sent as X-App-Key). The server secret never ships.

userIdfield
final String userId

The local user's identity (the caller/callee identity on the engine).

userNamefield
final String userName

The local user's display name.

baseUrlfield
final String baseUrl

The engine host for privileged in-call ops (Bearer). Grey-cloud origin.

tokenBaseUrlfield
final String tokenBaseUrl

The mint host for POST /api/v1/token + /api/v1/signal/token (X-App-Key).

themefield
final UTDCallsTheme theme

Color tokens for the built-in default call UI.

stringsfield
final UTDCallsStrings strings

User-facing strings for the built-in default call UI.

enableMinimizefield
final bool enableMinimize

Whether the in-call screen may be minimized to a floating overlay (and, when minimizeConfig opts in, Android OS PiP). Default true.

minimizeConfigfield
final UTDCallMinimizeConfig? minimizeConfig

Tuning for the minimize overlay / OS PiP. When null a sensible default (UTDCallMinimizeConfig) is used. Excluded from equality.

enableCallKitfield
final bool enableCallKit

Whether incoming calls are shown on the OS-native call UI via UTDCallKitBridge. Default true.

enablePushfield
final bool enablePush

Whether the kit registers device push tokens with the engine and wakes the app from background/killed on incoming calls. Default true.

copyWithmethod
UTDCallsConfig 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.

القيمة المُرجَعة: UTDCallsConfigA new config with the requested overrides applied.

propsgetter
List<Object?> get props

Equatable props used for value equality: appId, appKey, userId, userName, baseUrl, tokenBaseUrl, theme, strings, enableMinimize, enableCallKit, enablePush. Note minimizeConfig is intentionally excluded.

UTDCallMinimizeConfigclass
const 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القيمة الافتراضية = 110

    Default overlay tile width (logical px).

  • overlayHeightdoubleالقيمة الافتراضية = 150

    Default overlay tile height (logical px).

  • overlayBottomOffsetdoubleالقيمة الافتراضية = 120

    Initial inset of the overlay from the bottom of the screen.

  • overlayRightOffsetdoubleالقيمة الافتراضية = 16

    Initial inset of the overlay from the right of the screen.

  • borderRadiusdoubleالقيمة الافتراضية = 16

    Corner radius of the default overlay tile.

  • showEndButtonboolالقيمة الافتراضية = true

    Whether the default overlay shows a small end-call button.

  • enableOSPipboolالقيمة الافتراضية = false

    Enables 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القيمة الافتراضية = 9

    Numerator 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القيمة الافتراضية = 16

    Denominator of the PiP window aspect ratio. Defaults give a portrait 9:16 phone-call window.

onCloseproperty
final VoidCallback? onClose

Called when the floating overlay's end button is tapped (after the call is torn down).

overlayBuilderproperty
final UTDCallMiniOverlayBuilder? overlayBuilder

A fully custom overlay builder. When null the kit's default tile is used.

enableOSPipproperty
final bool enableOSPip

Enables Android OS-level Picture-in-Picture in addition to the in-app overlay (Android 12+/API 31+). Defaults to false (no behavior change).

UTDCallMiniOverlayBuildertypedef
typedef 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.

القيمة المُرجَعة: WidgetThe 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.

UTDCallStateclass
const 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.idle

    The current high-level phase of the call.

  • peerIdString?

    The remote party's identity.

  • peerNameString?

    The remote party's display name, when known.

  • typeUTDStreamTypeالقيمة الافتراضية = UTDStreamType.audioCall

    Whether this is a voice or video call.

  • callIdString?

    The engine call id, once assigned.

  • isOutgoingboolالقيمة الافتراضية = false

    Whether the local user is the caller (true) or the callee (false).

  • micMutedboolالقيمة الافتراضية = false

    Whether the local microphone is muted.

  • cameraOnboolالقيمة الافتراضية = false

    Whether the local camera is publishing; true from connect on a video call and toggled live by toggleCamera.

  • speakerOnboolالقيمة الافتراضية = false

    Whether audio is routed to the loudspeaker.

  • remoteJoinedboolالقيمة الافتراضية = false

    Whether 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.

phasefield
final UTDCallPhase phase

The current high-level phase of the call.

typefield
final UTDStreamType type

Whether this is a voice or video call.

endReasonfield
final UTDCallEndReason? endReason

Why the call ended, on a terminal UTDCallPhase.ended state; otherwise null.

connectedAtfield
final DateTime? connectedAt

When the call became active (the duration timer's epoch); null until the call connects.

peerLabelgetter
String? get peerLabel

The best label for the peer: peerName when non-empty, else peerId, else null.

القيمة المُرجَعة: String?Display name, falling back to identity, or null.

isInCallgetter
bool get isInCall

Whether a call is in any non-idle, non-ended phase.

القيمة المُرجَعة: boolTrue when phase is neither idle nor ended.

isVideogetter
bool get isVideo

Whether this is a video call (the call type carries video).

القيمة المُرجَعة: boolTrue when type.hasVideo is true.

durationgetter
Duration get duration

Elapsed call duration since connectedAt, or Duration.zero before connect.

القيمة المُرجَعة: DurationTime elapsed since the call connected.

copyWithmethod
UTDCallState 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.

القيمة المُرجَعة: UTDCallStateA new snapshot with the overrides applied.

UTDCallPhaseenum

The 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).

UTDCallEndReasonenum

Why 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).

UTDAudioRouteenum

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).

UTDStreamTypeenum

The 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).

wirefield
final String wire

The exact string the engine expects on the wire for this stream type, e.g. 'audio_call'.

isCallgetter
bool get isCall

Whether this stream type is a 1:1 call type (audioCall or videoCall).

القيمة المُرجَعة: boolTrue for audioCall or videoCall.

hasVideogetter
bool get hasVideo

Whether this stream type carries video (videoCall).

القيمة المُرجَعة: boolTrue for videoCall.

UTDCallInvitationclass
const 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.audioCall

    Whether the call is audio or video.

  • metadataMap<String, dynamic>?

    Arbitrary caller-supplied metadata, when any.

UTDCallInvitation.fromDataconstructor
factory 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.

UTDCallSignalKindenum

A 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).

UTDCallUpdateclass
const 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.fromFrameconstructor
factory 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).

utdCallSignalKindFromTypemethod
UTDCallSignalKind? 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.

UTDCallsClientclass
UTDCallsClient(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.

configfield
final UTDCallsConfig config

The kit configuration passed to the constructor (credentials, hosts, identity, flags).

القيمة المُرجَعة: UTDCallsConfig

apigetter
UTDApi get api

The REST facade used for mints and call actions (createCall/acceptCall/endCall, push token register, etc.).

القيمة المُرجَعة: UTDApi

signalgetter
UTDSignalClient get signal

The realtime signalling client (presence + incoming-call WebSocket).

القيمة المُرجَعة: UTDSignalClient

incomingCallsgetter
Stream<UTDCallInvitation> get incomingCalls

Stream of incoming 1:1 calls (the callee side), forwarded from the signal client.

القيمة المُرجَعة: Stream<UTDCallInvitation>

callUpdatesgetter
Stream<UTDCallUpdate> get callUpdates

Stream of progress on in-flight calls (ringing/accepted/rejected/busy/ended), forwarded from the signal client.

القيمة المُرجَعة: Stream<UTDCallUpdate>

forceExitgetter
Stream<UTDForceExitReason> get forceExit

Stream of server force-close events (single-active-session takeover, WS close code 4003).

القيمة المُرجَعة: Stream<UTDForceExitReason>

signalStategetter
ValueListenable<UTDConnectionState> get signalState

The signalling connection state as a ValueListenable.

القيمة المُرجَعة: ValueListenable<UTDConnectionState>

isInitializedgetter
bool get isInitialized

Whether init() has completed and the bearer is applied.

القيمة المُرجَعة: bool

initmethodasync
Future<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>

createSessionmethod
UTDCallSession 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

unregisterPushmethodasync
Future<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>

disposemethodasync
Future<void> dispose()

Dispose the transport (push dispatcher, signal client, and API client). Idempotent; the object must not be used afterwards.

القيمة المُرجَعة: Future<void>

UTDCallSessionclass
UTDCallSession({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.

statusfield
final ValueNotifier<UTDCallStatus?> status

The current call status as a ValueNotifier, or null before start()/accept(). Changes are forwarded to the registered handler's onCallStateChanged.

القيمة المُرجَعة: ValueNotifier<UTDCallStatus?>

callIdfield
final ValueNotifier<String?> callId

The current call id as a ValueNotifier, or null before start()/accept().

القيمة المُرجَعة: ValueNotifier<String?>

startmethodasync
Future<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.

acceptmethodasync
Future<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.

ringingmethodasync
Future<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>

rejectmethodasync
Future<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>

busymethodasync
Future<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>

endmethodasync
Future<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>

UTDSessionclass
UTDSession({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.

typefield
final UTDStreamType type

The product type this session serves.

القيمة المُرجَعة: UTDStreamType

roomfield
final UTDRoom room

The headless LiveKit room wrapper backing this session.

القيمة المُرجَعة: UTDRoom

setEventHandlermethod
void 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.

clearEventHandlermethod
void clearEventHandler()

Remove the registered event handler, if any.

connectionStategetter
ValueListenable<UTDConnectionState> get connectionState

The connection lifecycle state (mirrors the underlying room).

القيمة المُرجَعة: ValueListenable<UTDConnectionState>

connectedgetter
ValueListenable<bool> get connected

Whether the room is connected (boolean mirror of connectionState).

القيمة المُرجَعة: ValueListenable<bool>

remoteParticipantsgetter
ValueListenable<List<RemoteParticipant>> get remoteParticipants

The current remote participants in the room.

القيمة المُرجَعة: ValueListenable<List<RemoteParticipant>>

localParticipantgetter
LocalParticipant? get localParticipant

The local participant, or null before connecting.

القيمة المُرجَعة: LocalParticipant?

eventsgetter
Stream<RoomEvent> get events

The raw LiveKit RoomEvent firehose.

القيمة المُرجَعة: Stream<RoomEvent>

forceExitgetter
Stream<UTDForceExitReason> get forceExit

Fires once when the session is forcibly ended (ban / takeover / kick / reconnect timeout).

القيمة المُرجَعة: Stream<UTDForceExitReason>

setMicrophonemethodasync
Future<void> setMicrophone(bool enabled)

Toggle the local mic publish (works once the server has granted publish).

المعاملات

  • enabledboolمطلوب

    Whether the microphone should publish.

القيمة المُرجَعة: Future<void>

setSpeakerOnmethodasync
Future<void> setSpeakerOn(bool on)

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

المعاملات

  • onboolمطلوب

    True for loudspeaker, false for earpiece.

القيمة المُرجَعة: Future<void>

switchCameramethodasync
Future<void> switchCamera()

Switch between the front and back camera.

القيمة المُرجَعة: Future<void>

leavemethodasync
Future<void> leave()

Leave the media room but keep the session object reusable (disconnects without disposing).

القيمة المُرجَعة: Future<void>

disposemethodasync
Future<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>

UTDStreamEventHandlerclass
const 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).

UTDPushDispatcherclass
UTDPushDispatcher({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.

startmethodasync
Future<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.

coldStartAcceptedCallmethodasync
static 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.

disposemethodasync
Future<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.

appNamefield
final String appName

App name shown on the CallKit screen for FCM-driven incoming calls.

onTokensfield
final void Function({String? fcmToken, String? voipToken, required UTDPushPlatform platform}) onTokens

Callback invoked with the latest push tokens (fcmToken / voipToken, either nullable) and the current UTDPushPlatform whenever tokens are collected or refreshed.

UTDCallPushclass
const 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.audioCall

    Whether the call is audio (voice) or video. One of UTDStreamType.audioCall or UTDStreamType.videoCall.

tryParsemethod
static 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.

callIdfield
final String callId

The kit call_id to accept/join.

callerIdentityfield
final String callerIdentity

The caller's engine identity.

callerNamefield
final String? callerName

The caller's display name, when the engine provided one; otherwise null.

typefield
final UTDStreamType type

Whether the call is audio or video (UTDStreamType.audioCall or UTDStreamType.videoCall).

showCallkitForPushmethodasync
Future<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.

utdFirebaseBackgroundHandlermethodasync
Future<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.

UTDCallKitBridgeclass
UTDCallKitBridge({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.

eventsgetter
Stream<UTDCallKitEvent> get events

Broadcast 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.

startmethod
void start()

Begins bridging FlutterCallkitIncoming.onEvent into the events stream. Idempotent (no-op if already started or disposed).

showIncomingmethodasync
Future<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.

setConnectedmethodasync
Future<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.

endCallmethodasync
Future<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.

endAllCallsmethodasync
Future<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.

disposemethodasync
Future<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.

UTDCallKitEventclass
const 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).

actionfield
final UTDCallKitAction action

What happened on the native UI (a UTDCallKitAction value).

callIdfield
final String callId

The kit call_id the action refers to, or empty when it could not be mapped back to a known call.

UTDCallKitActionenum

What 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؟

أنشئ حسابك، اشحن محفظتك الأم، وشغّل الخدمات التي تحتاجها.