> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-audit-content-webhooks.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Outgoing Call

> Widget that serves as a visual representation of a user-initiated call, providing options to control the call experience.

<Accordion title="AI Agent Component Spec">
  ```json theme={null}
  {
    "component": "CometChatOutgoingCall",
    "package": "cometchat_calls_uikit",
    "import": "import 'package:cometchat_calls_uikit/cometchat_calls_uikit.dart';",
    "description": "Widget that serves as a visual representation of a user-initiated call, providing options to control the call experience.",
    "props": {
      "data": {
        "call": { "type": "Call", "required": true },
        "user": { "type": "User?", "default": "null" }
      },
      "callbacks": {
        "onCancelled": "Function(BuildContext context, Call call)?",
        "onError": "OnError?"
      },
      "viewSlots": {
        "subtitleView": "Widget? Function(BuildContext context, Call call)?",
        "avatarView": "Widget? Function(BuildContext context, Call call)?",
        "titleView": "Widget? Function(BuildContext context, Call call)?",
        "cancelledView": "Widget? Function(BuildContext context, Call call)?"
      },
      "style": {
        "outgoingCallStyle": "CometChatOutgoingCallStyle?"
      },
      "layout": {
        "height": { "type": "double?", "default": "null" },
        "width": { "type": "double?", "default": "null" }
      },
      "icons": {
        "declineButtonIcon": "Widget?"
      },
      "sound": {
        "disableSoundForCalls": { "type": "bool?", "default": "false" },
        "customSoundForCalls": "String?",
        "customSoundForCallsPackage": "String?"
      },
      "configuration": {
        "callSettingsBuilder": "CallSettingsBuilder?"
      }
    }
  }
  ```
</Accordion>

## Overview

The `CometChatOutgoingCall` [Widget](/ui-kit/android/components-overview#components) is a visual representation of a user-initiated call, whether it's a voice or video call. It serves as an interface for managing outgoing calls, providing users with essential options to control the call experience. This Widget typically includes information about the call recipient, call controls for canceling the call, and feedback on the call status, such as indicating when the call is in progress.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-content-webhooks/cD2BDn03AOl0XRHO/images/061fb439-outgoing_call-3f3bfded62daa83d53c24081b12f4d20.png?fit=max&auto=format&n=cD2BDn03AOl0XRHO&q=85&s=44684d94f556b4b5aa7d7549a56f72b7" width="2560" height="1600" data-path="images/061fb439-outgoing_call-3f3bfded62daa83d53c24081b12f4d20.png" />
</Frame>

You can launch `CometChatOutgoingCall` 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 `CometChatOutgoingCall`

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    Navigator.push(context, MaterialPageRoute(builder: (context) => CometChatOutgoingCall(user: user, call: callObject))); // User object and Call object is required to launch the incoming call widget.
    ```
  </Tab>
</Tabs>

##### 2. Embedding `CometChatOutgoingCall` as a Widget in the build Method

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    import 'package:cometchat_calls_uikit/cometchat_calls_uikit.dart';
    import 'package:flutter/material.dart';

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

      @override
      State<OutgoingCallExample> createState() => _OutgoingCallExampleState();
    }

    class _OutgoingCallExampleState extends State<OutgoingCallExample> {

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
            child: CometChatOutgoingCall(
                user: user, // User Object
                call: callObject
            ), // User object and Call object is required to launch the incoming call widget.
          ),
        );
      }
    }
    ```
  </Tab>
</Tabs>

***

### Actions

[Actions](/ui-kit/android/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

##### 1. onCancelled

The `onCancelled` action is typically triggered when the call is ended, carrying out default actions. However, with the following code snippet, you can effortlessly customize or override this default behavior to meet your specific needs.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
      user: user, // User Object
      call: callObject, // Call Object
      onCancelled: (BuildContext context, Call call) {
        // TODO("Not yet implemented")
      },
    )
    ```
  </Tab>
</Tabs>

***

##### 2. onError

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

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
      user: user, // User Object
      call: callObject, // Call Object
      onError: (e) {
        // TODO("Not yet implemented")
      },
    )
    ```
  </Tab>
</Tabs>

***

### 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 `CometChatOutgoingCall` Widget does not have any exposed filters.

***

### Events

[Events](/ui-kit/android/components-overview#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 Outgoing call Widget are as follows.

| Event              | Description                                  |
| ------------------ | -------------------------------------------- |
| **ccCallAccepted** | Triggers when the outgoing call is accepted. |
| **ccCallRejected** | Triggers when the outgoing call is rejected. |

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
    import 'package:flutter/material.dart';

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

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

    class _YourScreenState extends State<YourScreen> with CometChatCallEventListener {

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

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

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

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

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

    }
    ```
  </Tab>
</Tabs>

***

## 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 `CometChatOutgoingCall` Widget by applying the `CometChatOutgoingCallStyle` to it using the following code snippet.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
      user: user, // User Object
      call: callObject, // Call Object
      outgoingCallStyle: CometChatOutgoingCallStyle(
           avatarStyle: CometChatAvatarStyle(
              backgroundColor: Color(0xFFFBAA75),
              borderRadius: BorderRadius.circular(8),
           ),
           declineButtonColor: Color(0xFFF44649),
           declineButtonBorderRadius: BorderRadius.circular(12),
         )
    )
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-content-webhooks/qwv2C0wM1Djl_VYB/images/f6c6dd58-outgoing_call_styling-53873b73da0ff530f8199d30bd2eccd2.png?fit=max&auto=format&n=qwv2C0wM1Djl_VYB&q=85&s=50a5b545cdd76442777d631f4d50cdb3" width="2560" height="1600" data-path="images/f6c6dd58-outgoing_call_styling-53873b73da0ff530f8199d30bd2eccd2.png" />
</Frame>

***

### 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**

In this example, we're enhancing the interface by customizing the decline button icons. By setting custom icons for decline buttons, users can enjoy a more visually appealing and personalized experience.

This level of customization allows developers to tailor the user interface to match the overall theme and branding of their application.

**Example**

Here is the example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
        user: user, // User Object
        call: callObject, // Call Object
        disableSoundForCalls: true,
        declineButtonText: "Decline",
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-content-webhooks/9fXSeDIZdfRZBzT6/images/1ee27af8-outgoing_call_functionality_cometchat_screens-f0d6a773e40e452b68aa7c9b32462428.png?fit=max&auto=format&n=9fXSeDIZdfRZBzT6&q=85&s=6ea77d8c8a15811279289898bf60d38a" alt="Image" width="4498" height="3121" data-path="images/1ee27af8-outgoing_call_functionality_cometchat_screens-f0d6a773e40e452b68aa7c9b32462428.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-content-webhooks/-S5qACEOIWfW5CsV/images/78c18207-outgoing_call_functionality_cometchat_screens-62cac4f18b60221eab40245dc29ea2b0.png?fit=max&auto=format&n=-S5qACEOIWfW5CsV&q=85&s=44cac0a2dbfa616554d9f6f2b53d3989" alt="Image" width="4498" height="3121" data-path="images/78c18207-outgoing_call_functionality_cometchat_screens-62cac4f18b60221eab40245dc29ea2b0.png" />
  </Tab>
</Tabs>

Below is a list of customizations along with corresponding code snippets

| **Property**                       | Description                                                                       | Code                                        |
| ---------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------- |
| **Custom Sound For Calls**         | Sets the custom sound for outgoing calls.                                         | `customSoundForCalls: String?`              |
| **Custom Sound For Calls Package** | Sets the package for the custom sound for outgoing calls.                         | `customSoundForCallsPackage: String?`       |
| **Disable Sound For Calls**        | Disables sound for outgoing calls.                                                | `disableSoundForCalls: bool?`               |
| **Call**                           | Used to set the Call object against which we need to display the outgoing screen. | `call: Call`                                |
| **callSettingsBuilder**            | Sets the CallSettingsBuilder for the outgoing call configuration.                 | `callSettingsBuilder: CallSettingsBuilder?` |
| **declineButtonIcon**              | Sets decline button icon.                                                         | `declineButtonIcon: Widget?`                |

***

## Advanced

For advanced-level customization, you can set custom widgets 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 widgets, layouts, and UI elements and then incorporate those into the widget.

***

### titleView

Allows setting a custom title view to be rendered.

Use Cases:

* Display the contact’s name in a unique style.
* Show a call type indicator (Voice Call, Video Call).
* Add status text like "Calling..." or "Ringing...".

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
     titleView: (context, call) {
              // return titleView
          },
    )
    ```
  </Tab>
</Tabs>

***

### subTitleView

Allows setting a custom sub title view.

Use Cases:

* Display call duration if available.
* Show network strength indicators.
* Include a custom message like "Connecting...".

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
     subtitleView: (context, call) {
              // return subtitleView
          },
    )
    ```
  </Tab>
</Tabs>

***

### avatarView

Allows setting a custom avatar view.

Use Cases:

* Show a profile picture with an online indicator.
* Display a custom icon based on the call type (Voice/Video).
* Use an animated ring effect around the avatar when calling.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
     avatarView: (context, call) {
              // return avatrView
          },
    )
    ```
  </Tab>
</Tabs>

***

### cancelledView

Allows setting a custom cancelled view.

Use Cases:

* Customize the "End Call" button style.
* Add a confirmation pop-up before ending the call.
* Display different icons based on call status (Active, On Hold)..

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatOutgoingCall(
     cancelledView: (context, call) {
              // return cancelledView
          },
    )
    ```
  </Tab>
</Tabs>

***
