通过 Telegram Bot 向 Flutter 发送错误消息

Send error message Flutter via Telegram Bot

我尝试使用 Catcher,这是我的代码

CatcherOptions debugOptions = CatcherOptions(SilentReportMode(), [
    ConsoleHandler(),
    HttpHandler(HttpRequestType.post,
      Uri.parse("https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=-469322015&text="),
      printLogs: true,
    ),
    
  ]);

  Catcher(MyApp(), debugConfig: debugOptions, releaseConfig: releaseOptions);

一切正常,但我必须将错误信息输入此参数/sendMessage?chat_id=-469322015&text="Here Error Message"

请帮我怎么做

已通过创建自己的 ReportMode 解决

class SilentReportMode extends ReportMode {
  @override
  void requestAction(Report report, BuildContext context) {
    // no action needed, request is automatically accepted
    print("HEREEEEE ======= ${report.error}");
    try {
      sendError(report);
    } catch (e) {
    }
    super.onActionConfirmed(report);
  }

  Future sendError(Report report) async {
    try {
      Response response = await Dio().post('https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=-469322015&text=message: $report',
      );

      print("RESPONSE TELEGErammmmm ====== ${response.data}");
    } catch (e) {
      throw e;
    }
  }

  @override
  List<PlatformType> getSupportedPlatforms() =>
      [PlatformType.Web, PlatformType.Android, PlatformType.iOS];
}