uhst 0.0.1-nullsafety.0 copy "uhst: ^0.0.1-nullsafety.0" to clipboard
uhst: ^0.0.1-nullsafety.0 copied to clipboard


User Hosted Secure Transmission (uhst) for Flutter in Dart

Uhst #

User Hosted Secure Transmission (uhst) for Flutter in Dart

Pub Gitter GitHub

About #

Uhst is client library for the User Hosted Secure Transmission framework.

It is able to:

  • send messages from client and listen messages broadcasted from host
  • broadcast messages by host
  • listen messages from multiple clients by host

You can see an implemented example and source for it on GitHub

Please notice current version limitations:

  • it supports string typed messages only.
  • require server with Uhst implemented protocol. PLease see an example of ready to go server on GitHub.

Support and discussions #

Join us on Gitter or StackOverflow .

Usage #

Assuming you have loaded the library, first create a new instance:

var uhst = Uhst();

Refer to the documentation to learn about the options you can pass (including your own API / signalling server URL, WebRTC configuration, etc.) .

Host #

Host in UHST is a peer which every other peer connects to. This concept is similar to listen-server in multiplayer games.

Please be sure, before reconnecting to another host, to close previous connection.

The simplest way to create a new host is:

var host = uhst.host("testHost");


  ?..onReady(handler: ({required String hostId}) {
    setState(() {
      hostMessages.add('Host Ready! Using $hostId');
      print('host is ready!');
      _hostIdController.text = hostId;
  ..onError(handler: ({required Error error}) {
    print('error received! $error');
    if (error is HostIdAlreadyInUse) {
      // this is expected if you refresh the page
      // connection is still alive on the meeting point
      // just need to wait
      setState(() {
            .add('HostId already in use, retrying in 15 seconds...!');
    } else {
      setState(() {
  ..onConnection(handler: ({required UhstSocket uhstSocket}) {
    uhstSocket.onDiagnostic(handler: ({required String message}) {
      setState(() {

    uhstSocket.onMessage(handler: ({required Message? message}) {
      setState(() {
            .add("Host received: ${message?.body} ${message?.type}");
        var payload = message?.payload;
        if (payload != null) host?.broadcastString(message: payload);

    uhstSocket.onOpen(handler: ({required String? data}) {
      // uhstSocket.sendString(message: 'Host sent message!');

Note that your requested host id may not be accepted by the signalling server, you should always use the hostId you get after receiving a ready event when connecting to the host.

Client #

To connect to a host from another browser use the same hostId you received during onReady event.

Please be sure, before reconnecting to another host, to close previous connection.

var client = uhst.join("testHost");


  ?..onOpen(handler: ({required String data}) {
    setState(() {
      client?.sendString(message: 'Hello host!');
  ..onMessage(handler: ({required Message? message}) {
    setState(() {
      clientMessages.add('Client received: $message');
  ..onError(handler: ({required Error error}) {
    if (error is InvalidHostId || error is InvalidClientOrHostId) {
      setState(() {
        clientMessages.add('Invalid hostId!');
    } else {
      setState(() {
  ..onDiagnostic(handler: ({required String message}) {
    setState(() {

The UHST client interface is similar to the HTML5 WebSocket interface, but instead of a dedicated server, one peer acts as a host for other peers to join.

Once a client and a host have connected they can exchange messages asynchronously. Arbitrary number of clients can connect to the same host but clients cannot send messages to each other, they can only communicate with the host.

Documentation #

Visit our website for more complete documentation: https://docs.uhst.io.

Styling #

This project uses (Dart documentation style guidlines)[https://dart.dev/guides/language/effective-dart/documentation]

Generation #

The project uses (dartdoc)[https://github.com/dart-lang/dartdoc#dartdoc]

If you don't have installed dartdoc, then to install the latest version of dartdoc compatible with your SDK run:

  • pub global activate dartdoc
  • for Flutter Snap version run flutter pub global activate dartdoc

To generate documentation

  • run dartdoc
  • for Flutter Snap version run flutter pub global run dartdoc:dartdoc

View #

An easy way to run an HTTP server locally is to use the dhttpd package. For example:

$ pub global activate dhttpd
$ dhttpd --path doc/api

for Flutter Snap

$ flutter pub global activate dhttpd
$ flutter pub global run dhttpd:dhttpd --path doc/api

Contributing #

This project is maintained by a community of developers. Contributions are welcome and appreciated. You can find UHST on GitHub; feel free to start an issue or create a pull requests:

License #

Copyright (c) 2020 Uhst Licensed under MIT License.

pub points


verified publisheruhst.io

User Hosted Secure Transmission (uhst) for Flutter in Dart

Repository (GitHub)
View/report issues


unknown (LICENSE)


flutter, http, universal_html


Packages that depend on uhst