FastDecoder class

High-performance batch CSV decoder using byte-level (codeUnits) parsing.

Techniques:

  • Direct codeUnit array indexing (no string ops in hot loop)
  • Labeled loop control flow (outerLoop, cell_loop)
  • Type inference by first-byte detection
  • substring + replaceRange for quoted fields (avoids StringBuffer)
  • Row pre-sizing after first row for fewer allocations

Parsing semantics

All csv_plus decoders (this batch decoder, decodeStrings, and the streaming CsvDecoder) implement one shared semantics:

  • An empty line reads as a row with one empty field, per RFC 4180. With CsvConfig.skipEmptyLines (the default), rows consisting of a single empty field are dropped; rows of several empty fields (,,) are always kept.
  • Text after a closing quote is appended to the field, so "a"x reads ax (Excel behavior). With CsvConfig.strict it throws instead.
  • An unterminated quote consumes the rest of the input as field content (throws under CsvConfig.strict).
  • With CsvConfig.hasHeader, the first surviving row is the header row. Header cells are read as raw strings: no type inference, no CsvConfig.decoderTransform.
  • Quoted fields are never type-inferred; quoting opts a value out of CsvConfig.dynamicTyping.
Available extensions

Constructors

FastDecoder()
Create a batch decoder instance (stateless, reusable).
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decode(String input, CsvConfig config) List<List>
Decode CSV string with automatic type inference.
decodeBooleans(String input, CsvConfig config, {bool? emptyAs}) List<List<bool>>

Available on FastDecoder, provided by the FastDecoderFlexible extension

Decode all fields as booleans.
decodeDoubles(String input, CsvConfig config, {double? emptyAs}) List<List<double>>

Available on FastDecoder, provided by the FastDecoderFlexible extension

Decode all fields as doubles.
decodeFlexible(String input, CsvConfig config) List<List>

Available on FastDecoder, provided by the FastDecoderFlexible extension

Decode with lenient parsing: unquoted strings, whitespace trimming.
decodeIntegers(String input, CsvConfig config, {int? emptyAs}) List<List<int>>

Available on FastDecoder, provided by the FastDecoderFlexible extension

Decode all fields as integers.
decodeStrings(String input, CsvConfig config) List<List<String>>
Decode all fields as strings (no type inference overhead).
decodeWithHeaders(String input, CsvConfig config) → ({List<String> headers, List<List> rows})
Decode CSV string, returning the header row and typed data rows in a single pass.
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

inferType(String value) → dynamic
Infer a dynamic type from a string value.
isDelimiterAt(List<int> bytes, int pos, bool singleCharDelim, int firstDelim, List<int> delimBytes, int delimLen, int totalLen) bool
Check if current position is a field delimiter.
matchDelimiter(List<int> bytes, int pos, List<int> delimBytes, int delimLen, int totalLen) bool
Check if bytes match multi-char delimiter at position.