dial static method

Future<Call?> dial({
  1. required String receiverId,
  2. required String? receiverName,
  3. String? callerId,
  4. String? callerName,
  5. String? callerPic,
  6. String? receiverPic,
  7. bool? isvideocall = true,
  8. Map? data,
})

Implementation

static Future<Call?> dial({
  required String receiverId,
  required String? receiverName,
  String? callerId,
  String? callerName,
  String? callerPic,
  String? receiverPic,
  bool? isvideocall = true,
  Map? data,
}) async {
  bool isgranted = await CallHelper.permissions();
  if (isgranted == true) {
    Call? call;
    int timestamp = DateTime.now().millisecondsSinceEpoch;
    String channelName = '$loggedUsername-$timestamp';
    AgoraToken? agoraToken = await AgoraRepo().generateToken(channelName);
    if (agoraToken == null) {
      // AppUtils.showTopMessage(title: 'Token empty');
      return call;
    }
    call = Call(
      timeepoch: timestamp,
      callerId: callerId ?? loggedUsername,
      callerName: callerName ?? '${appPrefs.loginUser!.displayName}',
      callerPic: callerPic ?? appPrefs.loginUser!.thumbnail,
      receiverId: receiverId,
      receiverName: receiverName,
      receiverPic: receiverPic,
      channelId: channelName,
      channelToken: agoraToken.token,
      agoraAppId: agoraToken.appId,
      isvideocall: isvideocall,
      data: data,
    );
    await _makeCall(call: call);

    updateCallState(channelName,
        infoCall: call.toJson(),
        status: kCallStateCALLING,
        pickedAt: 0,
        endAt: 0);

    call.hasDialled = true;
    return call;
  } else {
    //showTopMessage(title: 'Access to camera, microphone denied');
  }
}