writeCsv function

String writeCsv(
  1. List<List<String>> rows, {
  2. String delimiter = ',',
  3. String eol = '\r\n',
  4. bool forceQuote = false,
})

Encodes rows as a full CSV document, joining lines with eol (default CRLF, the RFC 4180 line terminator). Each row is encoded with writeCsvLine using delimiter and forceQuote. Returns an empty string for no rows.

Example:

writeCsv([['h1', 'h2'], ['1', '2']]); // 'h1,h2\r\n1,2'

Audited: 2026-06-12 11:26 EDT

Implementation

String writeCsv(
  List<List<String>> rows, {
  String delimiter = ',',
  String eol = '\r\n',
  bool forceQuote = false,
}) => rows
    .map((List<String> r) => writeCsvLine(r, delimiter: delimiter, forceQuote: forceQuote))
    .join(eol);