webrtc_data_channel 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

Flutter WebRTC DataChannel plugin #

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

Install #

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'

Usage #

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),

Use this package as a library

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 pub get

Alternatively, your editor might support flutter pub 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';
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 20, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/webrtc_data_channel.dart.

Run flutter format to format lib/webrtc_data_channel.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/Piasy/webrtc_data_channel was unreachable.

Package is getting outdated. (-76.44 points)

The package was last published 92 weeks ago.


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 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8