pusher_dart 0.1.0+1

Pusher #

Unofficial pusher client for dart.

Usage #

Using this package is similar to how one would use PusherJS.

Initialize and connect #

import 'package:pusher_dart';

final pusher = Pusher(
        authEndpoint: DotEnv().env['PUSHER_AUTH_URL'],
        auth: PusherAuth(headers: {
          'Authorization': 'Bearer $apiToken',
          'Content-Type': 'application/json',
          'Accept': 'application/json'

Subscribe to a channel #

final channel = pusher.subscribe('my-channel');

Bind to events #

eventHandler(Object data) async {
    final jsonData = Map<String, Object>.from(jsonDecode(data));

channel.bind('my-event', eventHandler);

Trigger event on a channel #

You can pass any data that can be converted to JSON using jsonEncode(data);.

Map<String, String> jsonData = {};
channel.trigger('my-event', jsonData);

Close the connection #


[0.1.0+1] - 31/05/2019

Initial release with support for channels, events, and authorization.

Use this package as a library

1. Depend on it

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

  pusher_dart: ^0.1.0+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:pusher_dart/pusher_dart.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 Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-1 points)

44 out of 44 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/pusher_dart.dart. (-0.50 points)

Analysis of lib/pusher_dart.dart reported 1 hint:

line 107 col 7: DO use curly braces for all flow control structures.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and pusher_dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0 0.12.0+4
meta ^1.1.0 1.1.8
web_socket_channel ^1.0.0 1.1.0
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
http_parser 3.1.3
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6