flutter_webrtc 0.0.3

  • README.md
  • Example
  • Installing
  • Versions
  • 86


pub package Flutter WebRTC plugin for iOS/Android


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


Add the following entry to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

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

This entry allows your app to access camera and microphone.


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" />

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


We intend to implement support the following features:


import 'package:flutter/material.dart';
import 'package:flutter_webrtc/webrtc.dart';
import 'dart:core';

 * getUserMedia sample
class GetUserMediaSample extends StatefulWidget {
  static String tag = 'get_usermedia_sample';

  _GetUserMediaSampleState createState() => new _GetUserMediaSampleState();

class _GetUserMediaSampleState extends State<GetUserMediaSample> {
  MediaStream _localStream;
  final _localRenderer = new RTCVideoRenderer();
  bool _inCalling = false;

  initState() {

  deactivate() {
    if (_inCalling) {

  initRenderers() async {
    await _localRenderer.initialize();

  // Platform messages are asynchronous, so we initialize in an async method.
  _makeCall() async {
    final Map<String, dynamic> mediaConstraints = {
      "audio": true,
      "video": {
        "mandatory": {
          "minWidth":'640', // Provide your own width, height and frame rate here
          "minHeight": '480',
          "minFrameRate": '30',
        "facingMode": "user",
        "optional": [],

    try {
        _localStream = stream;
        _localRenderer.srcObject = _localStream;
    } catch (e) {
    if (!mounted) return;

    setState(() {
      _inCalling = true;

  _hangUp() async {
    try {
      await _localStream.dispose();
      _localRenderer.srcObject = null;
    } catch (e) {
    setState(() {
      _inCalling = false;

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('GetUserMedia API Test'),
      body: new OrientationBuilder(
        builder: (context, orientation) {
          return new Center(
            child: new Container(
              margin: new EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
              child: RTCVideoView(_localRenderer),
              decoration: new BoxDecoration(color: Colors.black54),
      floatingActionButton: new FloatingActionButton(
        onPressed: _inCalling ? _hangUp : _makeCall,
        tooltip: _inCalling ? 'Hangup' : 'Call',
        child: new Icon(_inCalling ? Icons.call_end : Icons.phone),

For more examples, please refer to flutter-webrtc-demo.


[0.0.3] - 2018.12.20

  • Update WebRTC to 1.0.25821.
  • Implemented MediaStreamTrack.setVolume().
  • Add public getter for texture id.
  • Fixed getUserMedia does not work for capturing audio only.

[0.0.2] - 2018.11.04

  • Add 'enabled' method for MediaStreamTrack.
  • Implement switch camera.
  • Add arm64-v8a and x86_64 architecture support for android.

[0.0.1] - 2018.05.30

  • Initial release.



Demonstrates how to use the webrtc plugin.

Getting Started

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_webrtc: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_webrtc/get_user_media.dart';
import 'package:flutter_webrtc/media_stream.dart';
import 'package:flutter_webrtc/media_stream_track.dart';
import 'package:flutter_webrtc/rtc_data_channel.dart';
import 'package:flutter_webrtc/rtc_dtmf_sender.dart';
import 'package:flutter_webrtc/rtc_ice_candidate.dart';
import 'package:flutter_webrtc/rtc_peerconnection.dart';
import 'package:flutter_webrtc/rtc_peerconnection_factory.dart';
import 'package:flutter_webrtc/rtc_session_description.dart';
import 'package:flutter_webrtc/rtc_stats_report.dart';
import 'package:flutter_webrtc/rtc_video_view.dart';
import 'package:flutter_webrtc/utils.dart';
import 'package:flutter_webrtc/webrtc.dart';
Version Uploaded Documentation Archive
0.0.3 Dec 20, 2018 Go to the documentation of flutter_webrtc 0.0.3 Download flutter_webrtc 0.0.3 archive
0.0.2 Nov 4, 2018 Go to the documentation of flutter_webrtc 0.0.2 Download flutter_webrtc 0.0.2 archive
0.0.1 Sep 11, 2018 Go to the documentation of flutter_webrtc 0.0.1 Download flutter_webrtc 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-0.88 points)

238 out of 239 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Fix lib/rtc_video_view.dart. (-1.99 points)

Analysis of lib/rtc_video_view.dart reported 4 hints:

line 22 col 8: The value of the field '_mirror' isn't used.

line 24 col 25: The value of the field '_objectFit' isn't used.

line 26 col 31: The value of the field '_eventSubscription' isn't used.

line 26 col 31: Cancel instances of dart.async.StreamSubscription.

Fix lib/rtc_data_channel.dart. (-1 points)

Analysis of lib/rtc_data_channel.dart reported 2 hints:

line 37 col 10: The value of the field '_label' isn't used.

line 64 col 16: The value of the local variable 'type' isn't used.

Fix lib/get_user_media.dart. (-0.50 points)

Analysis of lib/get_user_media.dart reported 1 hint:

line 6 col 7: Name types using UpperCamelCase.

Fix additional 8 files with analysis or formatting issues. (-0.50 points)

Additional issues in the following files:

  • lib/rtc_peerconnection.dart (1 hint)
  • lib/media_stream.dart (Run flutter format to format lib/media_stream.dart.)
  • lib/rtc_dtmf_sender.dart (Run flutter format to format lib/rtc_dtmf_sender.dart.)
  • lib/rtc_ice_candidate.dart (Run flutter format to format lib/rtc_ice_candidate.dart.)
  • lib/rtc_peerconnection_factory.dart (Run flutter format to format lib/rtc_peerconnection_factory.dart.)
  • lib/rtc_session_description.dart (Run flutter format to format lib/rtc_session_description.dart.)
  • lib/rtc_stats_report.dart (Run flutter format to format lib/rtc_stats_report.dart.)
  • lib/utils.dart (Run flutter format to format lib/utils.dart.)

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.35.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8