CallBundle class
CallBundle — Native incoming & outgoing call UI for Flutter.
This is the app-facing public API. Import package:callbundle/callbundle.dart
to access all functionality.
Quick Start
// 1. Configure once during app startup
await CallBundle.configure(NativeCallConfig(
appName: 'MyApp',
android: AndroidCallConfig(phoneAccountLabel: 'MyApp Calls'),
ios: IosCallConfig(includesCallsInRecents: true),
));
// 2. Listen for call events
CallBundle.onEvent.listen((event) {
switch (event.type) {
case NativeCallEventType.accepted:
print('Call ${event.callId} accepted by user');
break;
case NativeCallEventType.declined:
print('Call ${event.callId} declined');
break;
case NativeCallEventType.ended:
if (event.isUserInitiated) {
print('User ended call ${event.callId}');
} else {
print('Call ${event.callId} ended programmatically');
}
break;
default:
break;
}
});
// 3. Show incoming call (safe from background isolates)
await CallBundle.showIncomingCall(NativeCallParams(
callId: 'abc-123',
callerName: 'Ravi Kumar',
callType: NativeCallType.video,
extra: {'userId': '456', 'roomId': 'xyz'},
));
// 4. End a call programmatically
await CallBundle.endCall('abc-123');
Background Isolate Safety
showIncomingCall and endCall can be called from FCM background handlers without additional setup. The plugin automatically initializes BackgroundIsolateBinaryMessenger support.
Cold-Start Handling
When a user taps "Accept" while the app is killed, the plugin
stores the event in PendingCallStore. After the Dart side calls
configure, pending events are automatically delivered via onEvent.
No hardcoded delays are needed.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
onEvent
→ Stream<
NativeCallEvent> -
Stream of native call events.
no setter
-
onReady
→ Future<
void> -
Future that completes when the native side is fully initialized.
no setter
Static Methods
-
checkPermissions(
) → Future< NativeCallPermissions> - Checks current permission status without prompting the user.
-
configure(
NativeCallConfig config) → Future< void> - Initializes the CallBundle plugin with the given configuration.
-
dispose(
) → Future< void> - Releases all resources held by the plugin.
-
endAllCalls(
) → Future< void> - Ends all active calls.
-
endCall(
String callId) → Future< void> - Ends a specific call by its ID.
-
getActiveCalls(
) → Future< List< NativeCallInfo> > - Returns all currently active/tracked calls.
-
getVoipToken(
) → Future< String?> - Returns the current VoIP push token (iOS only).
-
requestBatteryOptimizationExemption(
) → Future< bool> - Requests battery optimization exemption from the system.
-
requestPermissions(
) → Future< NativeCallPermissions> - Requests permissions and returns the updated permission status.
-
setCallConnected(
String callId) → Future< void> - Marks a specific call as connected/active.
-
showIncomingCall(
NativeCallParams params) → Future< void> - Shows a native incoming call UI.
-
showOutgoingCall(
NativeCallParams params) → Future< void> - Shows a native outgoing call UI.