Skip to main content
Version: v5

Call Buttons

Overview

The CometChatCallButtons is a Widget provides users with the ability to make calls, access call-related functionalities, and control call settings. Clicking this button typically triggers the call to be placed to the desired recipient.

Image

Usage

Integration

You can launch CometChatCallButtons directly using Navigator.push, or you can define it as a widget within the build method of your State class.

1. Using Navigator to Launch CometChatCallButtons
Navigator.push(context, MaterialPageRoute(builder: (context) => CometChatCallButtons()));
2. Embedding CometChatCallButtons as a Widget in the build Method
import 'package:cometchat_calls_uikit/cometchat_calls_uikit.dart';
import 'package:flutter/material.dart';

class CallButtonsExample extends StatefulWidget {
const CallButtonsExample({super.key});


State<CallButtonsExample> createState() => _CallButtonsExampleState();
}

class _CallButtonsExampleState extends State<CallButtonsExample> {

Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: CometChatCallButtons()
)
),
);
}
}

Actions

Actions dictate how a widget functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the widget to fit your specific needs.

onError

You can customize this behavior by using the provided code snippet to override the onError and improve error handling.

CometChatCallButtons(
onError: (e) {
// TODO("Not yet implemented")
},
)

Filters

Filters allow you to customize the data displayed in a list within a Widget. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

The CallButton widget does not have any exposed filters.


Events

Events are emitted by a Widget. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

Events emitted by the Call buttons widget are as follows.

EventDescription
ccCallAcceptedTriggers when the outgoing call is accepted.
ccCallRejectedTriggers when the outgoing call is rejected.
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
import 'package:flutter/material.dart';

class YourScreen extends StatefulWidget {
const YourScreen({super.key});


State<YourScreen> createState() => _YourScreenState();
}

class _YourScreenState extends State<YourScreen> with CometChatCallEventListener {


void initState() {
super.initState();
CometChatCallEvents.addCallEventsListener("unique_listener_ID", this); // Add the listener
}


void dispose(){
super.dispose();
CometChatCallEvents.removeCallEventsListener("unique_listener_ID"); // Remove the listener
}


void ccCallAccepted(Call call) {
// TODO("Not yet implemented")
}


void ccCallRejected(Call call) {
// TODO("Not yet implemented")
}


Widget build(BuildContext context) {
return const Placeholder();
}

}

Customization

To fit your app's design requirements, you can customize the appearance of the conversation widget. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

You can customize the appearance of the CometChatCallButtons Widget by applying the CometChatCallButtonsStyle to it using the following code snippet.

CometChatCallButtons(
callButtonsStyle: CometChatCallButtonsStyle(
voiceCallIconColor: Color(0xFF6852D6),
videoCallIconColor: Color(0xFF6852D6),
voiceCallButtonColor: Color(0xFFEDEAFA),
videoCallButtonColor: Color(0xFFEDEAFA),
voiceCallButtonBorderRadius: BorderRadius.circular(12.5),
videoCallButtonBorderRadius: BorderRadius.circular(12.5),
videoCallButtonBorder: BorderSide(
color: Color(0xFFE8E8E8),
width: 1,
),
voiceCallButtonBorder: BorderSide(
color: Color(0xFFE8E8E8),
width: 1,
),
)
)

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the widget. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

Example

Here is the example for reference:

CometChatCallButtons(
hideVideoCallButton: true,
)
Image

Below is a list of customizations along with corresponding code snippets

PropertyDescriptionCode
UserUsed to set User object to the call button.user: User?
GroupUsed to set Group object to the call button.group: Group?
CallSettingsBuilderSets the call settings builder callback function. This callback is responsible for configuring the call settings based on the user, group, and call type (audio/video).callSettingsBuilder: CallSettingsBuilder?
Hide Video CallHides the video call button.hideVideoCallButton: bool?
Hide Voice CallHides the voice call button.hideVoiceCallButton: bool?
Video Call IconSets the icon for the video call button.videoCallIcon: Icon?
Voice Call IconSets the icon for the voice call button.voiceCallIcon: Icon?
outgoingCallConfigurationSets the configurations for outgoing call component.outgoingCallConfiguration: CometChatOutgoingCallConfiguration?

Advanced

For advanced-level customization, you can set custom views to the widget. This lets you tailor each aspect of the widget to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the widget.

The CometChatCallButtons widget does not provide additional functionalities beyond this level of customization.


Configurations

Configurations offer the ability to customize the properties of each individual component within a Composite Component.

  • Configurations expose properties that are available in its individual components.

Outgoing Call

You can customize the properties of the Outgoing Call component by making use of the OutgoingCallConfiguration. You can accomplish this by employing the OutgoingCallConfiguration as demonstrated below:

CometChatCallButtons(
outgoingCallConfiguration: CometChatOutgoingCallConfiguration(),
)

All exposed properties of OutgoingCallConfiguration can be found under Outgoing Call.