slack 2.0.0

dart-slack #

Dartlang interface to the Slack Webhook API

API Documentation available on Pub

Simple Start #

import 'package:slack/html/slack';
// or 
import 'package:slack/io/slack';

main() {
  Slack slack = new Slack('webhook-url');
  Message message = new Message('foo message',username:'bar-user');      
  slack.send(message);
}

Attachment Support #

Minimally attachments require a 'fallback' [String], in the first field.

Attachment bugReport = new Attachment("I can't use Slack!",
   pretext: 'A Critical Bug Reported',
   text   : "I can't use Slack!",
   color  : 'danger');

Message message = new Message('Bug Report:', username: 'bugBot', attachments: [bugReport]);
slack.send(message);

Cascades #

Messages, Attachments, and Fields are mostly just data containers. This means that you have a choice between setting their values in the constructor or setting them in a cascade. For example, Attachments could be defined like so:

Attachment bugReport = new Attachment("I can't use Slack!")
   ..pretext = 'A Critical Bug Reported'
   ..text   = "I can't use Slack!"
   ..color  = 'danger';

Message message = new Message('Bug Report:')
    ..username    = 'bugBot'
    ..attachments = [bugReport];
slack.send(message);

Use this package as a library

1. Depend on it

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


dependencies:
  slack: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:slack/html/slack.dart';
import 'package:slack/io/slack.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
58
Overall:
Weighted score of the above. [more]
68
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: web

Platform components identified in package: html, io.

Health suggestions

Fix lib/io/slack.dart. (-1 points)

Analysis of lib/io/slack.dart reported 2 hints:

line 3 col 8: Unused import: 'dart:async'.

line 4 col 8: Unused import: 'dart:io'.

Fix lib/src/slacksrc.dart. (-1 points)

Analysis of lib/src/slacksrc.dart reported 2 hints:

line 46 col 41: DO use curly braces for all flow control structures.

line 102 col 31: DO use curly braces for all flow control structures.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (http).

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 slack.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-2 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.11.2 0.11.3+17 0.12.0+2
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.7
path 1.6.2
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6

Admin