makeCall method

dynamic makeCall()

Implementation

makeCall() async {
  if (selectedUsersJIDList.isEmpty) {
    return;
  }
  if (!availableFeatures.value.isGroupCallAvailable.checkNull()) {
    Helper.showFeatureUnavailable(context);
    return;
  }
  if ((await Mirrorfly.isOnGoingCall()).checkNull()) {
    debugPrint("#Mirrorfly Call You are on another call");
    toToast(Constants.msgOngoingCallAlert);
    return;
  }
  if (!(await AppUtils.isNetConnected())) {
    toToast(Constants.noInternetConnection);
    return;
  }
  if (callType.value == CallType.audio) {
    if (!context.mounted) {
      mirrorFlyLog("Group participant Controller", "Context is not mounted");
    } else {
      if (await AppPermission.askAudioCallPermissions(context)) {
        Mirrorfly.makeGroupVoiceCall(
            groupJid: groupId.value,
            toUserJidList: selectedUsersJIDList,
            flyCallBack: (FlyResponse response) {
              if (response.isSuccess) {
                /*Get.offNamed(Routes.outGoingCallView,
              arguments: {"userJid": selectedUsersJIDList, "callType": CallType.audio});*/
                MirrorflyUikit.instance.navigationManager.navigateTo(
                    context: context,
                    pageToNavigate:
                        OutGoingCallView(userJid: selectedUsersJIDList),
                    routeName: Constants.outGoingCallView,
                    onNavigateComplete: () {});
              }
            });
      }
    }
  } else if (callType.value == CallType.video) {
    if (!context.mounted) {
      mirrorFlyLog("Group Participant Controller", "Context is not mounted");
    } else {
      if (await AppPermission.askVideoCallPermissions(context)) {
        Mirrorfly.makeGroupVideoCall(
            groupJid: groupId.value,
            toUserJidList: selectedUsersJIDList,
            flyCallBack: (FlyResponse response) {
              if (response.isSuccess) {
                /*Get.offNamed(Routes.outGoingCallView,
              arguments: {"userJid": selectedUsersJIDList, "callType": CallType.video});*/
                MirrorflyUikit.instance.navigationManager.navigateTo(
                    context: context,
                    pageToNavigate:
                        OutGoingCallView(userJid: selectedUsersJIDList),
                    routeName: Constants.outGoingCallView,
                    onNavigateComplete: () {});
              }
            });
      }
    }
  }
}