DEV Community

Dipen Maharjan
Dipen Maharjan

Posted on

Logging your error message of your Flutter App directly into Slack Channel?

Wanna know how to log your error message in #flutter to your slack channel ?

  1. Create new App in Slack

Go to https://api.slack.com/apps and create a new app.

Select from scratch option and in next option
Pick your appname and pick your workspace to send messages.

  1. Enable Incoming Webhooks
    After that, you need to enable incoming webhooks. and you will get the webhook url.

  2. Now create your flutter project or in your exisiting project
    In your terminal add this package slack_logger:

     

flutter pub add slack_logger
Enter fullscreen mode Exit fullscreen mode

now in your main.dart file

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {

    SlackLogger(webhookUrl: "[Add Your Web Hook Url]");

    return MaterialApp(
      ...
    );
  }
}
Enter fullscreen mode Exit fullscreen mode

now in your class:

final SlackLogger _slack = SlackLogger.instance;
Enter fullscreen mode Exit fullscreen mode

and in your try catch:

try {
  ...
} catch (e) {
  _slack.send(e.toString());
}
Enter fullscreen mode Exit fullscreen mode

Now when you get your error, you'll recieve the slack message in your selected channel.
Package Url : https://pub.dev/packages/slack_logger/
Github Url: https://github.com/slimpotatoboy/slack_logger
Feel Free to request any missing features or report issues here.

Image description

Top comments (0)