sendReport method
void
sendReport(
- String message,
- String date, {
- dynamic onError(
- ReportModel data,
- String deviceInfo
- Function? onSuccessSync,
Implementation
void sendReport(String message, String date,
{Function(ReportModel data, String deviceInfo)? onError,
Function? onSuccessSync}) async {
assert(chatId.isNotEmpty);
assert(botToken.isNotEmpty);
var deviceInfo = (await _device.getDeviceInfo());
var clipped = deviceInfo.ellipsize(800);
var data = ReportModel(
chartId: chatId,
text:
"<==============DEVICE=================> \n\n$clipped\n\n\n\n<==============ERROR=================>\n\n\n${message.ellipsize(3000)} \n\n\n$date");
try {
var response =
await _client.post("bot$botToken/sendMessage", data: data.toJson());
if (response.isSuccessful) onSuccessSync?.call();
} catch (e) {
onError?.call(data, deviceInfo);
}
}