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(
    DotEnv().env['PUSHER_APP_KEY'],
    PusherOptions(
        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 #

pusher.disconnect();

[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:


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:pusher_dart/pusher_dart.dart with components: io.

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0 0.12.0+2
meta ^1.1.0 1.1.7
web_socket_channel ^1.0.0 1.0.14
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
http_parser 3.1.3
path 1.6.2
pedantic 1.8.0+1
source_span 1.5.5
stream_channel 2.0.0
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6

Admin