Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/huhx/slack_notification

Slack notification in Dart
https://github.com/huhx/slack_notification

dart flutter slack

Last synced: 17 days ago
JSON representation

Slack notification in Dart

Awesome Lists containing this project

README

        

## Features
Incoming Webhooks are a simple way to post messages from apps into Slack. Creating an Incoming Webhook gives you a unique URL to which you send a JSON payload with the message text and some options. You can use all the usual formatting and layout blocks with Incoming Webhooks to make the messages stand out.

![Example message with attachment showing full range of fields](https://a.slack-edge.com/02c4a07/img/api/message_example_with_attachments.png)

**flutter pub**: [https://pub.dev/packages/slack_notification](https://pub.dev/packages/slack_notification)

## Getting started
Before use Incoming Webhooks, we need to create `Slack` app. The setup link: https://api.slack.com/messaging/webhooks

## Usage
After create `Slack` and add `Webhooks`, remeber the Webhook URL(this data is sentive include secret, just be careful).
### Add dependencies
```yaml
dependencies:
slack_notification: ^1.2.2
```

### Simple usage
```dart
final Message message = Message(
text: "person: Hello World. ${DateTime.now()}",
);

final Response response = await Slack(webHookUrl).send(
message: message,
);
```

### Advance usage
```dart
final Message message = Message(
text: "person: Hello World. ${DateTime.now()}",
blocks: [
SectionBlock(
text: {
"type": "mrkdwn",
"text": "Danny Torrence left the following review for your property:"
},
),
SectionBlock(
fields: [
{"type": "mrkdwn", "text": "*Average Rating*\n1.0"}
],
)
],
);

final Response response = await Slack(personUrl).send(
message: message,
);
```

`Block` or `Attachment`, refer to:
* Block:https://api.slack.com/reference/block-kit/blocks
* Attachents: https://api.slack.com/reference/messaging/attachments
> This feature of `Attachents` is a legacy part of messaging functionality for Slack apps. We recommend you stick with layout `blocks`

## Drop a ⭐ if it is help to you.