webrtc_data_channel 0.1.0

  • README.md
  • Example
  • Installing
  • Versions
  • new49

Flutter WebRTC DataChannel plugin

This plugin allows Flutter apps to use WebRTC DataChannel to establish P2P connection and exchange text messages.


Plugin dependency:

webrtc_data_channel: "^0.1.0"

WebRTC Android dependency:

rootProject.allprojects {
    repositories {
        maven {
            url  "https://google.bintray.com/webrtc"

dependencies {
    api 'org.webrtc:google-webrtc:1.0.22672'

WebRTC iOS dependency:

pod 'GoogleWebRTC', '1.1.22642'


import 'package:webrtc_data_channel/webrtc_data_channel.dart';

// create DataChannel and connect to room
WebRTCDataChannel _dataChannel = new WebRTCDataChannel();
_dataChannel.connect(_roomUrl, _roomId);

// listen for messages
_receivedMessages = _dataChannel.listenMessages()
        .listen((String message) {
            // handle message

// send message

// disconnect from room

Server setup

This plugin use webrtc/apprtc as room server and signal server, you can use https://appr.tc/ or deploy it yourself, I've a Docker image for it, piasy/apprtc-server.

Development setup

  • git clone https://github.com/Piasy/webrtc_data_channel
  • flutter create -t plugin webrtc_data_channel
  • cd webrtc_data_channel/example/ios && pod install

[0.1.0] - 2018.04.15

  • Initial release.


import 'package:flutter/material.dart';

import 'chat_room.dart';

void main() {
  runApp(new MaterialApp(
    home: new HomePage(),

class HomePage extends StatefulWidget {
  HomePageState createState() {
    return new HomePageState();

class HomePageState extends State<HomePage> {
  // https://appr.tc
  final TextEditingController _roomUrlController = new TextEditingController();
  final TextEditingController _roomIdController = new TextEditingController();

  BuildContext _scaffoldContext;

  _startChat(BuildContext context) {
    if (_roomUrlController.text.isNotEmpty &&
        _roomIdController.text.isNotEmpty) {
          new MaterialPageRoute(
              builder: (context) => new ChatRoom(
                  _roomUrlController.text, _roomIdController.text)));
    } else {
          new SnackBar(content: new Text('Please set room url and id')));

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('WebRTC DataChannel Chat'),
      body: new Builder(builder: (BuildContext context) {
        _scaffoldContext = context;
        return new Column(
          children: [
            new Container(
              padding: new EdgeInsets.fromLTRB(30.0, 30.0, 30.0, 0.0),
              child: new TextField(
                autofocus: true,
                controller: _roomUrlController,
                decoration: new InputDecoration(hintText: 'Type room url'),
            new Container(
              padding: new EdgeInsets.all(30.0),
              child: new TextField(
                controller: _roomIdController,
                decoration: new InputDecoration(hintText: 'Type room id'),
            new RaisedButton(
              child: new Text('CHAT'),
              onPressed: () => _startChat(context),

1. Depend on it

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

  webrtc_data_channel: "^0.1.0"

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:webrtc_data_channel/webrtc_data_channel.dart';
Version Uploaded Documentation Archive
0.1.0 Apr 16, 2018 Go to the documentation of webrtc_data_channel 0.1.0 Download webrtc_data_channel 0.1.0 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6
  • Flutter: 0.3.2


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
98 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


  • Package is pre-v1 release.

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/webrtc_data_channel.dart.


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.6 1.14.9
meta 1.1.2
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6