toMarkdownTable method

String toMarkdownTable({
  1. bool includeHeader = true,
})

Renders the matrix as a Markdown table.

Implementation

String toMarkdownTable({bool includeHeader = true}) {
  final rows = _matrix;
  final buffer = StringBuffer();
  if (includeHeader) {
    buffer.writeln('| sample | option | formatted |');
    buffer.writeln('| --- | --- | --- |');
  }
  for (final row in rows) {
    buffer.writeln('| ${row[0]} | ${row[1]} | ${row[2]} |');
  }
  return buffer.toString().trim();
}