CsvConfig class

Immutable configuration for CSV encoding/decoding.

Constructors

CsvConfig({String fieldDelimiter = ',', String lineDelimiter = '\r\n', String quoteCharacter = '"', String? escapeCharacter, QuoteMode quoteMode = QuoteMode.necessary, bool addBom = false, bool autoDetect = true, bool skipEmptyLines = true, bool hasHeader = false, bool dynamicTyping = true, bool parseDates = false, bool strict = false, String? comment, int skipRows = 0, int? maxRows, bool skipInitialSpace = false, Set<String> nullValues = const <String>{}, String? nullPlaceholder, dynamic decoderTransform(dynamic value, int index, String? header)?, dynamic encoderTransform(dynamic value, int index, String? header)?})
Create a CSV configuration.
const
CsvConfig.excel({String lineDelimiter = '\r\n', String quoteCharacter = '"', String? escapeCharacter, QuoteMode quoteMode = QuoteMode.necessary, bool skipEmptyLines = true, bool hasHeader = false, bool dynamicTyping = true, bool parseDates = false, bool strict = false, String? comment, int skipRows = 0, int? maxRows, bool skipInitialSpace = false, Set<String> nullValues = const <String>{}, String? nullPlaceholder, dynamic decoderTransform(dynamic value, int index, String? header)?, dynamic encoderTransform(dynamic value, int index, String? header)?})
Excel-compatible preset: ; delimiter, UTF-8 BOM, no auto-detect.
const
CsvConfig.pipe({String lineDelimiter = '\r\n', String quoteCharacter = '"', String? escapeCharacter, QuoteMode quoteMode = QuoteMode.necessary, bool addBom = false, bool skipEmptyLines = true, bool hasHeader = false, bool dynamicTyping = true, bool parseDates = false, bool strict = false, String? comment, int skipRows = 0, int? maxRows, bool skipInitialSpace = false, Set<String> nullValues = const <String>{}, String? nullPlaceholder, dynamic decoderTransform(dynamic value, int index, String? header)?, dynamic encoderTransform(dynamic value, int index, String? header)?})
Pipe-separated values preset.
const
CsvConfig.tsv({String lineDelimiter = '\r\n', String quoteCharacter = '"', String? escapeCharacter, QuoteMode quoteMode = QuoteMode.necessary, bool addBom = false, bool skipEmptyLines = true, bool hasHeader = false, bool dynamicTyping = true, bool parseDates = false, bool strict = false, String? comment, int skipRows = 0, int? maxRows, bool skipInitialSpace = false, Set<String> nullValues = const <String>{}, String? nullPlaceholder, dynamic decoderTransform(dynamic value, int index, String? header)?, dynamic encoderTransform(dynamic value, int index, String? header)?})
Tab-separated values preset.
const

Properties

addBom bool
Add UTF-8 BOM at start of encoded output.
final
autoDetect bool
Auto-detect field delimiter from input.
final
comment String?
Marker for comment lines to skip while decoding (for example #).
final
decoderTransform → dynamic Function(dynamic value, int index, String? header)?
Transform each field after decoding.
final
dynamicTyping bool
Automatically parse numbers and booleans from string fields.
final
encoderTransform → dynamic Function(dynamic value, int index, String? header)?
Transform each field before encoding.
final
escapeCharacter String
Escape character inside quoted fields. Defaults to quoteCharacter (RFC 4180 doubling).
final
fieldDelimiter String
Field delimiter. Supports single or multi-character.
final
hashCode int
The hash code for this object.
no setterinherited
hasHeader bool
Treat first row as column headers.
final
lineDelimiter String
Row delimiter for encoding. Decoding auto-detects line endings.
final
maxRows int?
Maximum number of data rows to return, or null (the default) for no limit.
final
nullPlaceholder String?
Text written for a null value when encoding.
final
nullValues Set<String>
Unquoted field values that decode to null instead of their own text.
final
parseDates bool
Automatically parse ISO-8601 dates and date-times into DateTime.
final
quoteCharacter String
Quote character. Must be single character.
final
quoteMode QuoteMode
When to quote fields during encoding.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
skipEmptyLines bool
Skip rows where all fields are empty.
final
skipInitialSpace bool
Drop spaces sitting between a delimiter and the start of a field.
final
skipRows int
Number of leading rows to skip before decoding begins.
final
strict bool
Throw CsvParseException on structurally malformed input instead of recovering: a character after a closing quote, or an unterminated quoted field at end of input.
final

Methods

copyWith({String? fieldDelimiter, String? lineDelimiter, String? quoteCharacter, String? escapeCharacter, QuoteMode? quoteMode, bool? addBom, bool? autoDetect, bool? skipEmptyLines, bool? hasHeader, bool? dynamicTyping, bool? parseDates, bool? strict, String? comment, int? skipRows, int? maxRows, bool? skipInitialSpace, Set<String>? nullValues, String? nullPlaceholder, dynamic decoderTransform(dynamic value, int index, String? header)?, dynamic encoderTransform(dynamic value, int index, String? header)?}) CsvConfig
Create a modified copy, overriding only the specified fields.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

needsQuoting(String value, String delim, String quote) bool
Whether value must be quoted when encoding with this config.