readAll method
Read all valid (CRC-verified) records from the WAL file.
Implementation
Future<List<WalRecord>> readAll() async {
final file = File(path);
if (!await file.exists()) return [];
List<String> lines;
try {
final bytes = await file.readAsBytes();
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;
}