Search packages, repositories and app categories

Package detailsv0.5.6

peerdart

Simple peer-to-peer with WebRTC for Dart. PeerJS port for Flutter.

AndroidiOSmacOSWindowsLinux
30-day downloads
481
Likes
78
Pub points
135

Install package

flutter pub add peerdart

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

peerdart is a Dart package that enables simple peer-to-peer communication using WebRTC, serving as a Flutter-compatible port of PeerJS. It facilitates real-time data and media exchange between devices without requiring a central server for routing. Designed for low-latency connections, it supports direct device-to-device communication across multiple platforms including Android, iOS, macOS, Windows, and Linux. Ideal for applications needing instant connectivity, such as video calls, live streaming, or collaborative tools.

Use cases

  • Real-time video calling
  • Live streaming
  • Collaborative applications
  • Direct device messaging
  • WebRTC-based chat apps

Key features

  • WebRTC-powered P2P connections
  • Cross-platform support
  • Simple API similar to PeerJS
  • Supports data and media channels
  • Automatic ICE/STUN handling

Suitable for

  • Developers building real-time apps in Flutter
  • Projects requiring direct device communication
  • Apps targeting multiple operating systems
  • Prototyping WebRTC features
  • Low-latency interactive experiences

Considerations

  • Requires network configuration (firewall/NAT)
  • Depends on signaling server for connection setup
  • Limited browser support (Flutter-only)
  • Performance varies with network quality
  • May need TURN servers for NAT traversal

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

PeerDart: Simple peer-to-peer with WebRTC

PeerDart provides a complete, configurable, and easy-to-use peer-to-peer API built on top of WebRTC, supporting both data channels and media streams.

PeerDart mirrors the design of peerjs. Find the documentation here..

Status

  • [x] Alpha: Under heavy development
  • [x] Public Alpha: Ready for testing. But go easy on us, there will be bugs and missing functionality.
  • [ ] Public Beta: Stable. No breaking changes expected in this version but possible bugs.
  • [ ] Public: Production-ready

Live Example

Here's an example application that uses both media and data connections: Example

Setup

Create a Peer

final Peer peer = Peer("pick-an-id");
// You can pick your own id or omit the id if you want to get a random one from the server.

Data connections

Connect

const conn = peer.connect("another-peers-id");

conn.on("open").listen((name) {
    conn.send("hi!");
})

Receive

peer.on<DataConnection>("connection").listen((connection) {

    // On peer closed.
    conn.on("close").listen((event) {
        setState(() {
            connected = false;
        });
    });

    // ....
})

Media calls

Call

final mediaStream = await navigator.mediaDevices
        .getUserMedia({"video": true, "audio": false});

    final conn = peer.call("peerId", mediaStream);

    // Do some stuff with stream
    conn.on<MediaStream>("stream").listen((event) {
      _remoteRenderer.srcObject = event;
      _localRenderer.srcObject = mediaStream;

      setState(() {
        inCall = true;
      });
    });
});

Answer

peer.on<MediaConnection>("call").listen((call) async {
    final mediaStream = await navigator.mediaDevices
        .getUserMedia({"video": true, "audio": false});

    call.answer(mediaStream);


    // on peer closed
    call.on("close").listen((event) {
        setState(() {
            inCall = false;
        });
    });

    // Get peer stream
    call.on<MediaStream>("stream").listen((event) {
        _localRenderer.srcObject = mediaStream;
        _remoteRenderer.srcObject = event;

        setState(() {
            inCall = true;
        });
    });
});

More examples

See more at example.

Support

Works both on mobile and web browsers (Chrome tested.).

Links

Documentation / API Reference
PeerServer

License

PeerDart is licensed under the MIT License.

Categories

Dependencies

Dependency list 5 items

Source repository

Projects using this package