toMarkdown method

String toMarkdown()

Implementation

String toMarkdown() {
  if (violations.isEmpty) {
    return '# flutter_a11y_lens report\n\nNo violations found.\n';
  }

  final buffer = StringBuffer()
    ..writeln('# flutter_a11y_lens report')
    ..writeln()
    ..writeln(
      '${violations.length} violation(s) found — '
      '${countBySeverity(A11ySeverity.error)} error, '
      '${countBySeverity(A11ySeverity.warning)} warning, '
      '${countBySeverity(A11ySeverity.info)} info.',
    )
    ..writeln()
    ..writeln('| Severity | Rule | Widget | Message |')
    ..writeln('| --- | --- | --- | --- |');

  for (final v in violations) {
    buffer.writeln(
      '| ${v.severity.name} | ${v.ruleId} | ${v.widgetType ?? '-'} '
      '| ${_escapeMarkdownCell(v.message)} |',
    );
  }

  return buffer.toString();
}