Skip to main content

Get Started

Please refer to https://flutter.dev/docs to deploy the Flutter development environment.

and make sure your Flutter SDK version is 2.x

Usage#

Add flutter_webrtc as a dependency in your pubspec.yaml file.

You can find the latest version here pub package

  flutter_webrtc: ^x.y.z

then run flutter pub get in your project.

Platform related settings#

iOS#

Add the following entry to your Info.plist file,

located in <project root>/ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key><string>$(PRODUCT_NAME) Camera Usage!</string><key>NSMicrophoneUsageDescription</key><string>$(PRODUCT_NAME) Microphone Usage!</string>

This entry allows your app to access camera and microphone.

Android#

Ensure the following permission is present in your Android Manifest file,

located in <project root>/android/app/src/main/AndroidManifest.xml:

<uses-feature android:name="android.hardware.camera" /><uses-feature android:name="android.hardware.camera.autofocus" /><uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

If you need to use a Bluetooth device, please add:

<uses-permission android:name="android.permission.BLUETOOTH" /><uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

The Flutter project template adds it, so it may already be there.

Also you will need to set your build settings to Java 8, because official WebRTC jar now uses static methods in EglBase interface. Just add this to your app level build.gradle:

android {    //...    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }}

If necessary, in the same build.gradle you will need to increase minSdkVersion of defaultConfig up to 21 (currently default Flutter generator set it to 16).

Important reminder#

When you compile the release apk, you need to add the following operations,

Edit <project root>/android/app/build.gradle

    buildTypes {        release {            // TODO: Add your own signing config for the release build.            // Signing with the debug keys for now, so `flutter run --release` works.            signingConfig signingConfigs.debug+            minifyEnabled true+            useProguard true++            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }

And create new file <project root>/android/app/proguard-rules.pro

## Flutter wrapper-keep class io.flutter.app.** { *; }-keep class io.flutter.plugin.**  { *; }-keep class io.flutter.util.**  { *; }-keep class io.flutter.view.**  { *; }-keep class io.flutter.**  { *; }-keep class io.flutter.plugins.**  { *; }-dontwarn io.flutter.embedding.**
## Flutter WebRTC-keep class com.cloudwebrtc.webrtc.** { *; }-keep class org.webrtc.** { *; }