InvergeDocs
FlutterAPI reference

Voice

Voice in the Flutter SDK.

import 'package:nexus_flutter/nexus.dart';
SymbolKindSummary
NexusVoiceclassNexus Voice — the client calling API.
VoiceCallStateenumCall state — the subset a client observes (mirrors the server machine).
VoiceCallStateXextension
VoiceEndpointTypeenum
VoiceCallDirectionenum
NexusJoinTokenclassEverything a client needs to join the media plane for one leg.
CallQualitySampleclassOne transport-quality sample the engine emits; reported to the control plane and surfaced to the app for a live quality indicator.
NexusCallclassImmutable snapshot of the current call, exposed via a ValueListenable.
NexusVoiceEngineabstract classThe media-transport seam.
VoiceEngineStateenum
NoopVoiceEngineclassDefault engine when none is registered: it does NO media.
NexusCallKitabstract classNative calling seam — CallKit (iOS) / ConnectionService (Android) + VoIP push.
CallKitActionTypeenum
CallKitActionclass
NoopCallKitclassNo-op default.
NexusVoiceOverlayclassThe SDK's built-in, auto-shown call screen.
NexusIvrStatusenumState of an in-app IVR (visual phone-tree) session.
NexusIvrSessionclass
NexusIvrOverlayclassThe SDK's built-in IVR menu screen.
showNexusIncomingCall()functionShow the native incoming-call UI directly from a voice push payload.

NexusVoice

class

Nexus Voice — the client calling API. Talks to the Voice control plane (/partner/voice/*), drives a pluggable NexusVoiceEngine for media and an optional NexusCallKit for the native call UI, and exposes the live call as a ValueListenable. Follows the SDK rule: it NEVER throws into the app — failures are logged and surface as a failed/ended call state.

View source

current

field
final ValueNotifier<NexusCall?> current

The current call (null when idle). Listen to drive your call UI.

View source

ivr

field
final ValueNotifier<NexusIvrSession?> ivr

The current in-app IVR menu session (null when not in a menu). Drives the built-in NexusIvrOverlay; listen to build your own support-menu UI.

View source

onIvr

field
void Function(Map<String, dynamic> instruction)? onIvr

Optional hook for IVR prompts returned by DTMF (play/collect instructions).

View source

init()

method
Future<void> init()

Turnkey setup — called automatically when voiceEnabled. Wires the SDK's BUILT-IN WebRTC engine + native call UI (CallKit/ConnectionService) and registers this device for incoming-call push so calls ring even when the app is killed. Developers do NOT call this.

View source

rebindIdentity()

method
Future<void> rebindIdentity()

Re-bind voice to the CURRENT identity — MUST be called after identify()/reset(). Voice initialises at app start (before login), so it first binds to voice:<deviceKey>; without re-binding, an identified user keeps listening on the device room and never rings on voice:<distinctId>. Re-joins the correct room and re-registers the push device under the new id.

View source

useEngine()

method
void useEngine(NexusVoiceEngine engine)

Advanced override — replace the built-in WebRTC engine.

Parameters

Prop

Type

View source

useCallKit()

method
void useCallKit(NexusCallKit callKit)

Advanced override — replace the built-in native call UI.

Parameters

Prop

Type

View source

registerPushToken()

method
Future<bool> registerPushToken({String? voipToken, String? fcmToken})

Register this device's push tokens (iOS VoIP / Android FCM) for incoming calls when the app is backgrounded/killed. The SDK does this automatically; call it yourself with a token if your app owns FCM/OneSignal and wants to hand the SDK the exact token. Returns true once a token was registered.

Parameters

Prop

Type

Returns Future<bool>

View source

ensurePermissions()

method
Future<bool> ensurePermissions()

Request the microphone permission a voice call needs, returning whether it is granted. Call this from your onboarding (a foreground moment with UI context) so an incoming call answered later from a killed/background state — where no permission dialog can be shown — already has audio access. The SDK also pre-warms it on voice init, but calling it during onboarding with your own rationale is the best UX.

Returns Future<bool>

View source

openMicrophoneSettings()

method
Future<bool> openMicrophoneSettings()

Open this app's OS settings page so the user can grant the microphone after a permanent denial — iOS never re-prompts once the user has refused, so this is the only way back. Returns true if the settings page was opened.

Returns Future<bool>

View source

placeCall()

method
Future<NexusCall?> placeCall({required String to, VoiceEndpointType type = VoiceEndpointType.app, String? callerId, String? displayName, String? callerDisplayName, String? callerAvatarUrl, bool record = false, Map<String, dynamic> metadata = const {}})

Place a call to to — a Nexus identity (app), a phone number (pstn) or a SIP URI. This device joins as a WebRTC leg; the control plane dials to.

Parameters

Prop

Type

Returns Future<NexusCall?>

View source

handleIncomingPush()

method
Future<void> handleIncomingPush(Map<String, dynamic> data, {bool alreadyRinging = false})

Handle an incoming-call push/data message. Call this from your FCM / VoIP push handler with the payload the backend sent ({sessionId, from, ...}). Shows the native incoming UI and arms answer/decline.

Parameters

Prop

Type

View source

answer()

method
Future<void> answer([String? sessionId])

Answer the current inbound call — join as a WebRTC leg.

Parameters

Prop

Type

View source

decline()

method
Future<void> decline()

Decline the current inbound call.

View source

startIvr()

method
Future<bool> startIvr(String flowId)

Open an in-app IVR menu (a visual phone-tree) for flowId — e.g. a support entry point built in the dashboard. The built-in NexusIvrOverlay renders it; the caller taps keys to navigate, and the SDK auto-connects a real call when the flow routes to an agent. Returns false if the menu couldn't start.

Parameters

Prop

Type

Returns Future<bool>

View source

pressIvrKey()

method
Future<void> pressIvrKey(String digit)

Press a key in the current IVR menu.

Parameters

Prop

Type

View source

endIvr()

method
void endIvr()

Dismiss the IVR menu (the user backed out).

View source

hangup()

method
Future<void> hangup()
View source

setMuted()

method
Future<void> setMuted(bool muted)

Parameters

Prop

Type

View source

setSpeakerphone()

method
Future<void> setSpeakerphone(bool on)

Parameters

Prop

Type

View source

setHold()

method
Future<void> setHold(bool held)

Parameters

Prop

Type

View source

sendDtmf()

method
Future<void> sendDtmf(String digit)

Parameters

Prop

Type

View source

setPresence()

method
Future<void> setPresence(String status)

Parameters

Prop

Type

View source

dispose()

method
void dispose()
View source

VoiceCallState

enum
enum VoiceCallState

Call state — the subset a client observes (mirrors the server machine).

ValueDescription
VoiceCallState.idle
VoiceCallState.connecting
VoiceCallState.ringing
VoiceCallState.connected
VoiceCallState.onHold
VoiceCallState.reconnecting
VoiceCallState.ending
VoiceCallState.ended
VoiceCallState.failed
VoiceCallState.rejected
VoiceCallState.cancelled
VoiceCallState.timeout
View source

VoiceCallStateX

extension
extension VoiceCallStateX on VoiceCallState
View source

isTerminal

property
bool get isTerminal
View source

isActive

property
bool get isActive
View source

VoiceEndpointType

enum
enum VoiceEndpointType
ValueDescription
VoiceEndpointType.webrtc
VoiceEndpointType.sip
VoiceEndpointType.pstn
VoiceEndpointType.app
View source

VoiceCallDirection

enum
enum VoiceCallDirection
ValueDescription
VoiceCallDirection.inbound
VoiceCallDirection.outbound
View source

NexusJoinToken

class

Everything a client needs to join the media plane for one leg. Minted by the control plane; the client never fabricates any of it.

View source

NexusJoinToken

constructor
const NexusJoinToken({required this.room, required this.token, required this.url, this.turnUrls = const [], this.turnUsername, this.turnPassword})

Parameters

Prop

Type

View source

tryParse()

static method
static NexusJoinToken? tryParse(Map<String, dynamic>? join)

Parameters

Prop

Type

Returns NexusJoinToken?

View source

room

field
final String room
View source

token

field
final String token
View source

url

field
final String url
View source

turnUrls

field
final List<String> turnUrls
View source

turnUsername

field
final String? turnUsername
View source

turnPassword

field
final String? turnPassword
View source

CallQualitySample

class

One transport-quality sample the engine emits; reported to the control plane and surfaced to the app for a live quality indicator.

View source

CallQualitySample

constructor
const CallQualitySample({this.rttMs, this.jitterMs, this.packetLoss, this.bitrateKbps, this.mos, this.codec, this.candidateType})

Parameters

Prop

Type

View source

rttMs

field
final int? rttMs
View source

jitterMs

field
final int? jitterMs
View source

packetLoss

field
final double? packetLoss
View source

bitrateKbps

field
final int? bitrateKbps
View source

mos

field
final double? mos
View source

codec

field
final String? codec
View source

candidateType

field
final String? candidateType
View source

toJson()

method
Map<String, Object?> toJson()

Returns Map<String, Object?>

View source

NexusCall

class

Immutable snapshot of the current call, exposed via a ValueListenable.

View source

NexusCall

constructor
const NexusCall({required this.sessionId, required this.direction, required this.state, this.legId, this.remoteAddress, this.remoteName, this.remoteAvatar, this.muted = false, this.onHold = false, this.speakerphone = false, this.startedAt, this.connectedAt, this.quality, this.endReason, this.metadata = const {}})

Parameters

Prop

Type

View source

sessionId

field
final String sessionId
View source

legId

field
final String? legId
View source

direction

field
final VoiceCallDirection direction
View source

state

field
final VoiceCallState state
View source

remoteAddress

field
final String? remoteAddress
View source

remoteName

field
final String? remoteName
View source

remoteAvatar

field
final String? remoteAvatar
View source

muted

field
final bool muted
View source

onHold

field
final bool onHold
View source

speakerphone

field
final bool speakerphone
View source

startedAt

field
final DateTime? startedAt
View source

connectedAt

field
final DateTime? connectedAt
View source

quality

field
final CallQualitySample? quality
View source

endReason

field
final String? endReason
View source

metadata

field
final Map<String, dynamic> metadata
View source

copyWith()

method
NexusCall copyWith({String? legId, VoiceCallState? state, bool? muted, bool? onHold, bool? speakerphone, DateTime? connectedAt, CallQualitySample? quality, String? endReason})

Parameters

Prop

Type

Returns NexusCall

View source

NexusVoiceEngine

abstract class
abstract class NexusVoiceEngine

The media-transport seam. Nexus Voice's control plane is engine-agnostic; the actual WebRTC connection to the media plane (LiveKit) is provided by a NexusVoiceEngine. Ship a real engine by registering one via Nexus.instance.voice.useEngine(...) — e.g. a thin adapter over livekit_client (see the SDK README). Keeping media out of the core keeps the base package dependency-light and lets any transport slot in.

View source

states

property
Stream<VoiceEngineState> get states

Transport state changes (local connection to the media room).

View source

remoteCount

property
Stream<int> get remoteCount

Number of REMOTE participants in the room. The call is "connected" (the other party answered/joined) when this is > 0; it drops when they leave.

View source

quality

property
Stream<CallQualitySample> get quality

Periodic quality samples (reported to the control plane + shown in-app).

View source

connect()

method
Future<void> connect(NexusJoinToken token)

Connect to the media plane for a leg and start capturing/playing audio.

Parameters

Prop

Type

View source

disconnect()

method
Future<void> disconnect()

Tear down the media connection.

View source

setMuted()

method
Future<void> setMuted(bool muted)

Parameters

Prop

Type

View source

setSpeakerphone()

method
Future<void> setSpeakerphone(bool on)

Parameters

Prop

Type

View source

sendDtmf()

method
Future<void> sendDtmf(String digit)

Send a DTMF digit over the media session (RFC 4733).

Parameters

Prop

Type

View source

VoiceEngineState

enum
enum VoiceEngineState
ValueDescription
VoiceEngineState.connecting
VoiceEngineState.connected
VoiceEngineState.reconnecting
VoiceEngineState.disconnected
VoiceEngineState.failed
View source

NoopVoiceEngine

class
class NoopVoiceEngine implements NexusVoiceEngine

Default engine when none is registered: it does NO media. It logs and reports a connected state so control-plane flows can be exercised end-to-end without audio (useful in tests / before wiring a real transport). It never throws.

View source

states

property
Stream<VoiceEngineState> get states
View source

remoteCount

property
Stream<int> get remoteCount
View source

quality

property
Stream<CallQualitySample> get quality
View source

connect()

method
Future<void> connect(NexusJoinToken token)

Parameters

Prop

Type

View source

disconnect()

method
Future<void> disconnect()
View source

setMuted()

method
Future<void> setMuted(bool muted)

Parameters

Prop

Type

View source

setSpeakerphone()

method
Future<void> setSpeakerphone(bool on)

Parameters

Prop

Type

View source

sendDtmf()

method
Future<void> sendDtmf(String digit)

Parameters

Prop

Type

View source

NexusCallKit

abstract class
abstract class NexusCallKit

Native calling seam — CallKit (iOS) / ConnectionService (Android) + VoIP push. The SDK reports call lifecycle to the OS so incoming calls ring on the lock screen and in-call actions come from the system UI. Provide a real implementation (e.g. over flutter_callkit_incoming) via Nexus.instance.voice.useCallKit(...). The default is a no-op so the SDK runs without the native dependency.

View source

actions

property
Stream<CallKitAction> get actions

Actions the user takes from the system UI (answer / decline / mute / …).

View source

reportIncoming()

method
Future<void> reportIncoming({required String callId, required String handle, String? displayName, String? avatarUrl, bool hasVideo = false})

Show the system incoming-call UI. Returns when displayed.

Parameters

Prop

Type

View source

reportOutgoing()

method
Future<void> reportOutgoing({required String callId, required String handle, String? displayName})

Start a native OUTGOING call entry (configures the VoIP audio session).

Parameters

Prop

Type

View source

reportConnected()

method
Future<void> reportConnected(String callId)

Tell the OS the call connected (starts its timer / active-call UI).

Parameters

Prop

Type

View source

reportEnded()

method
Future<void> reportEnded(String callId)

Tell the OS the call ended (dismisses the call UI).

Parameters

Prop

Type

View source

voipToken()

method
Future<String?> voipToken()

The current VoIP push token (APNs PushKit / FCM), for the app to register with the backend so incoming calls can wake a killed app. Null if none.

Returns Future<String?>

View source

CallKitActionType

enum
enum CallKitActionType
ValueDescription
CallKitActionType.answer
CallKitActionType.decline
CallKitActionType.end
CallKitActionType.muted
CallKitActionType.hold
CallKitActionType.dtmf
View source

CallKitAction

class View source

CallKitAction

constructor
const CallKitAction(this.type, this.callId, {this.value})

Parameters

Prop

Type

View source

type

field
final CallKitActionType type
View source

callId

field
final String callId
View source

value

field
final Object? value
View source

NoopCallKit

class
class NoopCallKit implements NexusCallKit

No-op default. The SDK still works for in-app (foreground) calling; the OS call UI simply isn't shown until a real CallKit implementation is registered.

View source

actions

property
Stream<CallKitAction> get actions
View source

reportIncoming()

method
Future<void> reportIncoming({required String callId, required String handle, String? displayName, String? avatarUrl, bool hasVideo = false})

Parameters

Prop

Type

View source

reportOutgoing()

method
Future<void> reportOutgoing({required String callId, required String handle, String? displayName})

Parameters

Prop

Type

View source

reportConnected()

method
Future<void> reportConnected(String callId)

Parameters

Prop

Type

View source

reportEnded()

method
Future<void> reportEnded(String callId)

Parameters

Prop

Type

View source

voipToken()

method
Future<String?> voipToken()

Returns Future<String?>

View source

NexusVoiceOverlay

class
class NexusVoiceOverlay extends StatefulWidget

The SDK's built-in, auto-shown call screen. Renders full-screen whenever there is an active call (Nexus.instance.voice.current) — outbound and incoming — with mute / speaker / hold / hangup (and accept / decline while ringing inbound). Auto-mounted when voiceEnabled; opt out with NexusConfig(autoShowOverlay: false) and place your own UI, or wrap NexusVoiceOverlay yourself.

View source

NexusVoiceOverlay

constructor
const NexusVoiceOverlay({super.key, this.child})

Parameters

Prop

Type

View source

child

field
final Widget? child
View source

NexusIvrStatus

enum
enum NexusIvrStatus

State of an in-app IVR (visual phone-tree) session. The caller sees the current prompt; when awaitingInput is true a keypad is shown and each press calls NexusVoice.pressIvrKey. On reaching a "talk to an agent" step the SDK connects a real call automatically (status → connecting), and the NexusIvrSession clears once that call takes over.

ValueDescription
NexusIvrStatus.active
NexusIvrStatus.connecting
NexusIvrStatus.ended
View source

NexusIvrSession

class View source

NexusIvrSession

constructor
const NexusIvrSession({required this.sessionId, this.prompt, this.awaitingInput = false, this.maxDigits = 1, this.status = NexusIvrStatus.active, this.endedReason})

Parameters

Prop

Type

View source

sessionId

field
final String sessionId
View source

prompt

field
final String? prompt
View source

awaitingInput

field
final bool awaitingInput
View source

maxDigits

field
final int maxDigits
View source

status

field
final NexusIvrStatus status
View source

endedReason

field
final String? endedReason
View source

copyWith()

method
NexusIvrSession copyWith({String? prompt, bool? awaitingInput, int? maxDigits, NexusIvrStatus? status, String? endedReason})

Parameters

Prop

Type

Returns NexusIvrSession

View source

NexusIvrOverlay

class
class NexusIvrOverlay extends StatelessWidget

The SDK's built-in IVR menu screen. Auto-shown whenever an IVR session is active (alongside NexusVoiceOverlay); opt out with autoShowOverlay: false and build your own from Nexus.instance.voice.ivr.

View source

NexusIvrOverlay

constructor
const NexusIvrOverlay({super.key})

Parameters

Prop

Type

View source

Functions

showNexusIncomingCall()

function
Future<void> showNexusIncomingCall(Map<dynamic, dynamic> data)

Show the native incoming-call UI directly from a voice push payload.

Only needed on Android, where the incoming-call push is an FCM data message the SDK handles in a background Dart isolate. On iOS the ring is raised natively from the APNs VoIP (PushKit) payload before Dart is involved at all, so nothing here runs on that path.

The SDK wires its own FCM background handler, so apps do not normally call this; it stays public for apps that own their FCM handler end to end.

Parameters

Prop

Type

View source

On this page