readAll method
Reads the entire queue in FIFO order.
Implementation
@override
Future<List<SyncOperation>> readAll() async {
_ensureReady();
try {
final contents = await _file.readAsString();
final decoded = jsonDecode(contents);
if (decoded is! List) {
throw const FormatException('The queue root must be a JSON list.');
}
return List<SyncOperation>.unmodifiable(
decoded.map((Object? item) {
if (item is! Map) {
throw const FormatException('Each queue item must be an object.');
}
return SyncOperation.fromJson(Map<String, Object?>.from(item));
}),
);
} on Object catch (error) {
throw SyncStoreException(
'Could not read the queue file at $path.',
cause: error,
);
}
}