decodeList<E> method

  1. @override
List<E> decodeList<E>({
  1. Decodable<E>? using,
})
override

Decodes the data as a list of elements.

Optionally takes a Decodable to decode the elements of the list.

Implementation

@override
List<E> decodeList<E>({Decodable<E>? using}) {
  if (using == null) {
    throw CodableException.unexpectedType(expected: 'Decodable', actual: '$E');
  }

  final rows = <E>[];

  while (_offset < buffer.length) {
    if (buffer[_offset] != tokenLineFeed) {
      throw CodableException.unexpectedType(expected: 'end of line', data: buffer, offset: _offset);
    }
    _offset++;
    if (_offset >= buffer.length) {
      break;
    }
    rows.add(using.decode(CsvRowDecoder._(this)));
  }

  return rows;
}