startSession static method

Future<Widget?>? startSession(
  1. String callToken,
  2. CallSettings callSettings, {
  3. required dynamic onSuccess(
    1. Widget? callingWidget
    ),
  4. required dynamic onError(
    1. CometChatCallsException excep
    ),
})

Starts a call session.

  • callToken: The call token.
  • callSettings: The call settings.
  • onSuccess: A callback function that is called when the call session is successfully started.
  • onError: A callback function that is called when an error occurs while starting the call session.

Example: CometChatCalls.startSession( callToken: '<YOUR_CALL_TOKEN>', callSettings: <YOUR_CALL_SETTINGS>, onSuccess: (callingWidget) { // The call session was successfully started. }, onError: (error) { // An error occurred while starting the call session. }, );

Implementation

static Future<Widget?>? startSession(String callToken, CallSettings callSettings, {
  required Function(Widget? callingWidget) onSuccess,
  required Function(CometChatCallsException excep) onError
}) async{
  try{
    final callingViewWidget = await CometchatcallsPluginPlatform.instance.startSession(callToken, callSettings, onSuccess, onError);
    return callingViewWidget;
  }catch(e){
    CometChatCallsUtils.showLog("CometChatCall", "startSession: error: ${e.toString()}");
    onError(CometChatCallsException("Error", "Unable to start call session", e.toString()));
  }
  return null;
}