setupHtmlMessageText method

String setupHtmlMessageText(
  1. Report report
)

Setup html email message from report.

Implementation

String setupHtmlMessageText(Report report) {
  final buffer = StringBuffer();
  if (emailHeader?.isNotEmpty == true) {
    buffer
      ..write(_escapeHtmlValue(emailHeader ?? ''))
      ..write('<hr><br>');
  }

  buffer
    ..write('<h2>Error:</h2>')
    ..write(_escapeHtmlValue(report.error.toString()))
    ..write('<hr><br>');
  if (enableStackTrace) {
    buffer.write('<h2>Stack trace:</h2>');

    _escapeHtmlValue(report.stackTrace.toString())
        .split('\n')
        .forEach((element) {
      buffer.write('$element<br>');
    });
    buffer.write('<hr><br>');
  }
  if (enableDeviceParameters) {
    buffer.write('<h2>Device parameters:</h2>');
    for (final entry in report.deviceParameters.entries) {
      buffer
          .write('<b>${entry.key}</b>: ${_escapeHtmlValue(entry.value)}<br>');
    }
    buffer.write('<hr><br>');
  }
  if (enableApplicationParameters) {
    buffer.write('<h2>Application parameters:</h2>');
    for (final entry in report.applicationParameters.entries) {
      buffer
          .write('<b>${entry.key}</b>: ${_escapeHtmlValue(entry.value)}<br>');
    }
    buffer.write('<br><br>');
  }

  if (enableCustomParameters) {
    buffer.write('<h2>Custom parameters:</h2>');
    for (final entry in report.customParameters.entries) {
      buffer
          .write('<b>${entry.key}</b>: ${_escapeHtmlValue(entry.value)}<br>');
    }
    buffer.write('<br><br>');
  }

  return buffer.toString();
}