hacklink al hack forum organik hit kayseri escort b-ok zeta library books z libraryfghgfdhgfdhfgdhfghgfdhgfdhfgdhdeneme bonusu veren sitelerkumar sitelericasino metropolcasinomaxijojobetcasibomcasino siteleridsgdfgsdfggdfgsgdfgsdfgdonami bonasi voren satolitdonami bonasi voren satolitdizipalcasino sitelericasibom girişcasibomcasibom girişHoliganbetkopazarpadişahbet girişgrandpashabetmaç izleselçuk sports canlı maç izlemeritkingpadişahbet

Post Details Page

At Devhq.in, we provide comprehensive digital solutions for businesses. From software development and app creation to social media management and brand design, we help you build and grow your digital presence.

Audio Call in Flutter with ZegoCloud

ZEGOCLOUD is a cloud-based totally platform that gives builders with the tools they want to build real-time audio and video verbal exchange applications. The platform gives a selection of capabilities, including SDKs, APIs, and documentation, that make it clean to create audio and video applications. ZEGOCLOUD is used by a selection of groups and groups, which includes video conferencing corporations, stay streaming systems, and online schooling providers.
ZEGOCLOUD uses the modern day generation to deliver audio and video calling.
ZEGOCLOUD affords a numerous selection of development kits for software program introduction, appropriate for numerous programming languages.The Flutter SDK has been tailor-made to beautify the improvement of audio and video communique packages on mobile devices, delivering a comprehensive and dependable collection of tools to assist builders.

With the ZEGOCLOUD Flutter SDK, developers have a powerful set of equipment to create audio calling apps learn how to create an audio call app with Flutter right here. on this tutorial, we are able to guide you through the method of building an audio call app the usage of the ZEGOCLOUD Flutter SDK.


To increase an audio call utility with ZEGOCLOUD Flutter SDK, you need to first gather App ID and App Sign from the ZEGOCLOUD Console. those identifiers are essential on your app to set up a reference to the ZEGOCLOUD platform and access its audio and video communication functionalities.
Follow these steps to obtain App ID and an App Sign:
1.get entry to the ZEGOCLOUD Console internet site Console.

2.sign up for an account with the aid of offering your personal info.

3.After registering, you may be precipitated to create a new venture. click at the “Create” button to begin.

Create project

4.supply your task a call and select an appropriate area. Then, click at the “Create” button to continue.

5.As soon as your undertaking is created, you will be taken to the task dashboard

Note: The App Sign is a confidential value that should not be disclosed to others. Ensure it is kept safe and secure.

Constructing the Flutter App

Now allow create the Flutter utility:

To create the project, use the command “flutter create flutter_AudioCall”.

After creating the project, we need to install the zego_uikit_prebuilt_call
using the command flutter pub add zego_uikit_prebuilt_call.
Launch your preferred IDE and make necessary adjustments to ensure the smooth functioning of the project. Access android/app/build.gradle and modify the below-listed values:

  1. compileSdkVersion 33
  2. minSdkVersion 22

3.targetSdkVersion 33


it is necessary to specify the permissions that the application would require. this can be executed with the aid of adding the permission declarations in the occur tag within the AndroidManifest.xmlfile:

 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!-- only invitation -->
    <uses-permission android:name="android.permission.VIBRATE"/>


To enable the required functionality on IOS, please ensure that the following permissions have been added to your Info.plist file:

Audio Call Page

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sampark/Config/Strings.dart';
import 'package:sampark/Controller/ChatController.dart';
import 'package:sampark/Controller/ProfileController.dart';
import 'package:sampark/Model/UserMode.dart';
import 'package:zego_uikit_prebuilt_call/zego_uikit_prebuilt_call.dart';

class AudioCallPage extends StatelessWidget {
  final UserModel target;
  const AudioCallPage({super.key, required this.target});

  @override
  Widget build(BuildContext context) {
    ProfileController profileController = Get.put(ProfileController());
    ChatController chatController = Get.put(ChatController());
    var callId = chatController.getRoomId(target.id!);
    return ZegoUIKitPrebuiltCall(
      appID: ZegoCloudConfig.appId,
      appSign: ZegoCloudConfig.appSign,
      userID: profileController.currentUser.value.id ?? "root",
      userName: profileController.currentUser.value.name ?? "root",
      callID: callId,
      config: ZegoUIKitPrebuiltCallConfig.oneOnOneVoiceCall(),
    );
  }
}


// 123

CallController.dart

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sampark/Model/AudioCall.dart';
import 'package:sampark/Model/UserMode.dart';
import 'package:sampark/Pages/CallPage/AudioCallPage.dart';
import 'package:uuid/uuid.dart';
import 'package:zego_uikit_prebuilt_call/zego_uikit_prebuilt_call.dart';

class CallController extends GetxController {
  final db = FirebaseFirestore.instance;
  final auth = FirebaseAuth.instance;
  final uuid = Uuid().v4();

  void onInit() {
    super.onInit();

    getCallsNotification().listen((List<AudioCallModel> callList) {
      if (callList.isNotEmpty) {
        var callData = callList[0];
        Get.snackbar(
          duration: Duration(days: 1),
          barBlur: 0,
          backgroundColor: Colors.grey[900]!,
          isDismissible: false,
          icon: Icon(Icons.call),
          onTap: (snack) {
            Get.back();
            Get.to(
              AudioCallPage(
                target: UserModel(
                  id: callData.callerUid,
                  name: callData.callerName,
                  email: callData.callerEmail,
                  profileImage: callData.callerPic,
                ),
              ),
            );
          },
          callData.callerName!,
          "Incoming Call",
          mainButton: TextButton(
            onPressed: () {
              endCall(callData);
              Get.back();
            },
            child: Text("End Call"),
          ),
        );
      }
    });
  }

  Future<void> callAction(UserModel reciver, UserModel caller) async {
    String id = uuid;
    var newCall = AudioCallModel(
      id: id,
      callerName: caller.name,
      callerPic: caller.profileImage,
      callerUid: caller.id,
      callerEmail: caller.email,
      receiverName: reciver.name,
      receiverPic: reciver.profileImage,
      receiverUid: reciver.id,
      receiverEmail: reciver.email,
      status: "dialing",
    );

    try {
      await db
          .collection("notification")
          .doc(reciver.id)
          .collection("call")
          .doc(id)
          .set(newCall.toJson());
      await db
          .collection("users")
          .doc(auth.currentUser!.uid)
          .collection("calls")
          .doc(id)
          .set(newCall.toJson());
      await db
          .collection("users")
          .doc(reciver.id)
          .collection("calls")
          .doc(id)
          .set(newCall.toJson());
      Future.delayed(Duration(seconds: 20), () {
        endCall(newCall);
      });
    } catch (e) {
      print(e);
    }
  }

  Stream<List<AudioCallModel>> getCallsNotification() {
    return FirebaseFirestore.instance
        .collection("notification")
        .doc(auth.currentUser!.uid)
        .collection("call")
        .snapshots()
        .map((snapshot) => snapshot.docs
            .map((doc) => AudioCallModel.fromJson(doc.data()))
            .toList());
  }

  Future<void> endCall(AudioCallModel call) async {
    try {
      await db
          .collection("notification")
          .doc(call.receiverUid)
          .collection("call")
          .doc(call.id)
          .delete();
    } catch (e) {
      print(e);
    }
  }
}

Share now :

Facebook
Twitter
LinkedIn
Review Your Cart
0
Add Coupon Code
Subtotal