pusher 0.3.0

  • README.md
  • Example
  • Installing
  • Versions
  • 56

Pusher HTTP Dart Library

Build Status Coverage Status Pub Status

The Dart library for interacting with the Pusher HTTP API.

This package lets you trigger events to your client and query the state of your Pusher channels. When used with a server, you can authenticate private- or presence-channels.

In order to use this library, you need to have a free account on http://pusher.com. After registering, you will need the application credentials for your app.

Getting Started

import 'package:pusher/pusher.dart';

main() async {
  Pusher pusher = new Pusher('PUSHER_APP_ID','PUSHER_APP_KEY','PUSHER_APP_SECRET');
  Map data = {'message':'Hello world'};
  Response response = await pusher.trigger(['test_channel'],'my_event',data);


There easiest way to configure the library is by creating a new Pusher instance:

Pusher pusher = new Pusher(

Additional options

PusherOptions options = new PusherOptions(encrypted: true);
Pusher pusher = new Pusher(


Triggering events

It is possible to trigger an event on one or more channels. Channel names can contain only characters which are alphanumeric, _ or `-``. Event name can be at most 200 characters long too.

 Response response = await pusher.trigger(['test_channel'],'my_event',data);

Authenticating Channels

Pusher provides a mechanism for authenticating a user's access to a channel at the point of subscription.

This can be used both to restrict access to private channels, and in the case of presence channels notify subscribers of who else is also subscribed via presence events.

This library provides a mechanism for generating an authentication signature to send back to the client and authorize them.

For more information see docs.

Private channels

 String socketId = '74124.3251944';
 String auth = pusher.authenticate('test_channel',socketId);

Authenticating presence channels

Using presence channels is similar to private channels, but in order to identify a user, clients are sent a user_id and, optionally, custom data.

 String socketId = '74124.3251944';
 User user = new User('1',{'name':'Adao'});
 String auth = pusher.authenticate('presence-test_channel',socketId,user);

It is possible to query the state of your Pusher application using the generic pusher.get( resource ) method and overloads.

For full details see: http://pusher.com/docs/rest_api

Application state

This library allows you to query our API to retrieve information about your application's channels, their individual properties, and, for presence-channels, the users currently subscribed to them.

List channels

You can get a list of channels that are present within your application:

Response result = await pusher.get("/channels");

You can provide additional parameters to filter the list of channels that is returned.

Response result = await pusher.get("/channels", { "filter_by_prefix" : "presence-" } );

Fetch channel information

Retrive information about a single channel:

Response result = await pusher.get("/channels/my_channel");

Fetch a list of users on a presence channel

Retrive a list of users that are on a presence channel:

Response result = await pusher.get('/channels/presence-channel/users');




This code is free to use under the terms of the MIT license.


import 'package:pusher/pusher.dart';

main() async {
  Pusher pusher = new Pusher('PUSHER_APP_ID', 'PUSHER_APP_KEY', 'PUSHER_APP_SECRET');
  Map data = {'message': 'Hello world'};
  await pusher.trigger(['test_channel'], 'my_event', data);

Use this package as a library

1. Depend on it

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

  pusher: "^0.3.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or 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:pusher/pusher.dart';
Version Uploaded Documentation Archive
0.3.0 Jul 22, 2016 Go to the documentation of pusher 0.3.0 Download pusher 0.3.0 archive
0.2.0+1 Oct 7, 2015 Go to the documentation of pusher 0.2.0+1 Download pusher 0.2.0+1 archive
0.2.0 Oct 7, 2015 Go to the documentation of pusher 0.2.0 Download pusher 0.2.0 archive
0.1.0 Sep 17, 2015 Go to the documentation of pusher 0.1.0 Download pusher 0.1.0 archive


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

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


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


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:pusher/pusher.dart.


  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Package is getting outdated.

    The package was released 98 weeks ago.

  • The description is too short.

    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-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 7 hints.

    Strong-mode analysis of lib/src/pusher.dart gave the following hint:

    line: 69 col: 14
    'JSON' is deprecated and shouldn't be used.

    Strong-mode analysis of lib/src/trigger.dart gave the following hint:

    line: 49 col: 12
    'JSON' is deprecated and shouldn't be used.

    Similar analysis of the following files failed:

    • lib/src/utils.dart (hint)
  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.9.0 <2.0.0
crypto ^2.0.1 2.0.3
http ^0.11.3+2 0.11.3+16
Transitive dependencies
async 2.0.7
charcode 1.1.1
collection 1.14.10
convert 2.0.1
http_parser 3.1.2
path 1.6.0
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test >=0.12.0 <0.13.0