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 ?
- 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.
2. Enable Incoming Webhooks
After that, you need to enable incoming webhooks. and you will get the webhook url.
3. Now create your flutter project or in your exisiting project
In your terminal add this package slack_logger:
flutter pub add slack_logger
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(
...
);
}
}
now in your class:
final SlackLogger _slack = SlackLogger.instance;
and in your try catch:
try {
...} catch (e) { _slack.send(e.toString());}
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.