readAll method

Future<List<WalRecord>> readAll()

Implementation

Future<List<WalRecord>> readAll() async {
  final bytes = await _vfs.readAll(path);
  if (bytes.isEmpty) return [];

  List<String> lines;
  try {
    lines = const Utf8Decoder(allowMalformed: true)
        .convert(bytes)
        .split('\n');
  } catch (_) {
    return [];
  }

  final records = <WalRecord>[];
  for (final line in lines) {
    if (line.trim().isEmpty) continue;
    final rec = WalRecord.tryDecode(line);
    if (rec != null) records.add(rec);
  }
  return records;
}