zego_express_engine 1.18.0
zego_express_engine: ^1.18.0

Flutter Android iOS

ZegoExpressEngine Flutter SDK is a flutter plugin wrapper based on ZegoExpressEngine native Android / iOS SDK, providing live video and real-time audio/video services.

zego_express_engine pub package #

English | 中文

ZegoExpressEngine Audio/Video Flutter SDK is a flutter plugin wrapper based on ZegoExpressEngine native Android / iOS SDK, providing live video and real-time audio/video services. It only needs 4 lines of code and can be easily accessed in 30 minutes.

Learn more about the solution: https://www.zego.im

Example demo

  1. https://github.com/zegoim/zego-express-flutter-sdk/tree/master/example

    A simple publish & play stream example demo, in the example directory of this repository, shows the basic function of the SDK.

  2. https://github.com/zegoim/zego-express-example-screen-capture-flutter

    An example demo that implements screen capture and live broadcast on iOS/Android.

1️⃣ Download and Install Flutter #

Flutter Get Started #

2️⃣ Configuration development environment #

  • Android Studio: Preferences -> Plugins, search for the Flutter plugin to download, configure the first step to download the Flutter SDK path in the plugin.

  • VS Code: Search for the Flutter extension in the app store and download

After configuring the flutter environment in any of the above development environments, execute the flutter doctor on the command line and complete the related undownloaded dependencies according to the prompts.

3️⃣ Apply for ZEGO AppID #

Log in to ZEGO Official Website to register an account, select a scenario according to your actual business needs, and obtain AppID and App Sign for initializing the SDK.

4️⃣ Import zego_express_engine #

Open the pubspec.yaml in the project and add the zego_express_engine dependency:

dependencies:
  flutter:
  sdk: flutter

  zego_express_engine: ^1.18.0
  • Depends on git #

dependencies:
  flutter:
  sdk: flutter

  zego_express_engine:
    git:
      url: git://github.com/zegoim/zego-express-flutter-sdk.git
      ref: master

After saving the file, execute flutter pub get

5️⃣ Add device permissions #

Android #

Open the file app/src/main/AndroidManifest.xml, and add the following contents:

Add Android Privacy

    <!-- Permissions required by the SDK -->
    <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" />
    <!-- Permissions required by the App -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

Note: Because Android 6.0 requires dynamic permissions for some of the more important permissions, you cannot apply for static permissions only through the AndroidMainfest.xml file. Therefore, you need to refer to the following code (requestPermissions is the Activity method)

String[] permissionNeeded = {
        "android.permission.CAMERA",
        "android.permission.RECORD_AUDIO"};

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (ContextCompat.checkSelfPermission(this, "android.permission.CAMERA") != PackageManager.PERMISSION_GRANTED ||
        ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(permissionNeeded, 101);
    }
}

iOS #

Choose the option TARGETS -> Info -> Custom iOS Target Properties

Add iOS Privacy

Click the + Add button to add camera and microphone permissions.

  1. Privacy - Camera Usage Description

  2. Privacy - Microphone Usage Description

After adding permissions, it will be as shown:

Add iOS Privacy Done

If you use Platform View, you need to add an additional description for iOS, refer to FAQ-1

6️⃣ Init SDK #

import 'package:flutter/material.dart';
import 'package:zego_express_engine/zego_express_engine.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
    String version = 'Unknown';

    // Apply AppID and AppSign from ZEGO
    final int appID = 1234567890;

    // Apply AppID and AppSign from ZEGO
    final String appSign = 'abcdefghijklmnopqrstuvwzyv123456789abcdefghijklmnopqrstuvwzyz123';

    // Specify test environment
    final bool isTestEnv = true;

    // Specify a general scenario
    final ZegoScenario scenario = ZegoScenario.General;

    @override
    void initState() {
        super.initState();

        // Get SDK Version
        ZegoExpressEngine.getVersion().then((ver) {
            setState(() {
              version = ver;
            });
        });

        // Create ZegoExpressEngine
        ZegoExpressEngine.createEngine(appID, appSign, isTestEnv, scenario);
    }

    @override
    Widget build(BuildContext context) {
        return MaterialApp(
            home: Scaffold(
                appBar: AppBar(
                    title: const Text('ZegoExpressEngine'),
                ),
                body: Center(
                    child: Text('Version: $version\n'),
                ),
            ),
        );
    }
}

Please refer to the API documentation for more features.

7️⃣ API documentation #

ZegoExpressEngine API Reference

8️⃣ FAQ #

1. iOS: error when using Platform View: [VERBOSE-2:platform_view_layer.cc(28)] Trying to embed a platform view but the PaintContext does not support embedding #

Open the iOS project that requires Platform View and add the field io.flutter.embedded_views_preview to Info.plist with a value of YES.

iOS-Enable-PlatformView-Guide

2. iOS: fatal error: lipo: -extract armv7 specified but fat file: [...] does not contain that architecture #

Usually occurs when switching iOS devices, which can be resolved by deleting the flutter-project-path/build/ and flutter-project-path/ios/DerivedData/ directories. (If you cannot find the DerivedData folder, please look for /Users/your-user-name/Library/Developer/Xcode/DerivedData/)

3. iOS: Error when compiling: CDN: trunk URL couldn't be downloaded or CDN: trunk Repo update failed #

Open the Terminal terminal cd into the ios folder in the root directory of your project (the directory where the Podfile file is located) and execute pod repo update.

It is usually caused by a poor Internet connection in mainland China. It is recommended to turn on the proxy. Please refer to iOS CocoaPods FAQ

4. Android: building release crashes with NoClassDefFoundError when Flutter is upgraded to v1.10 or above #

Flutter is enabled obfuscation by default in version 1.10 or above. Please add the following line in app/proguard-rules.pro to prevent the SDK obfuscation.

-keep class **.zego.**{*;}

9️⃣ How to contribute #

We welcome contributions, information on how to get started can be found at our contributor guide.

6
likes
90
pub points
65%
popularity

ZegoExpressEngine Flutter SDK is a flutter plugin wrapper based on ZegoExpressEngine native Android / iOS SDK, providing live video and real-time audio/video services.

Homepage

Documentation

API reference

Uploaders

paaatrickfu@gmail.com
qypengzai@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on zego_express_engine